index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item prop="code">
  5. <el-input v-model="queryParams.code" placeholder="请输入编号" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item prop="name">
  8. <el-input v-model="queryParams.name" placeholder="请输入名称" clearable @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. <el-form-item prop="status">
  11. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
  12. <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  17. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd" v-hasPermi="['cloth:texture:add']">新增</el-button>
  23. </el-col>
  24. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  25. </el-row>
  26. <Page uri="/mapi/cloth/texture/list" :request-params="queryParams" ref="pagination">
  27. <el-table-column label="编号" align="center" prop="code" />
  28. <el-table-column label="名称" align="center" prop="name" />
  29. <el-table-column label="状态" align="center" prop="status">
  30. <template slot-scope="scope">
  31. <el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="创建人" align="center" prop="createBy" />
  35. <el-table-column label="创建时间" align="center" prop="createTime" />
  36. <el-table-column label="修改人" align="center" prop="updateBy" />
  37. <el-table-column label="修改时间" align="center" prop="createTime" />
  38. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  39. <template slot-scope="scope">
  40. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['cloth:texture:edit']">修改</el-button>
  41. <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['cloth:texture:remove']">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </Page>
  45. <!-- 添加或修改衣服质地对话框 -->
  46. <el-dialog :title="title" :visible.sync="open" width="50%" append-to-body>
  47. <el-row :gutter="15">
  48. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  49. <el-col :span="24">
  50. <el-form-item label="编号" prop="code">
  51. <el-input v-model="form.code" placeholder="请输入编号" />
  52. </el-form-item>
  53. <el-form-item label="名称" prop="name">
  54. <el-input v-model="form.name" placeholder="请输入名称" />
  55. </el-form-item>
  56. <el-form-item label="状态" prop="status">
  57. <el-radio-group v-model="form.status">
  58. <el-radio-button v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
  59. </el-radio-group>
  60. </el-form-item>
  61. </el-col>
  62. </el-form>
  63. </el-row>
  64. <div slot="footer" class="dialog-footer">
  65. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  66. <el-button @click="cancel">取 消</el-button>
  67. </div>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import { listTexture, getTexture, delTexture, addTexture, updateTexture, updateTextureStatus } from '@/api/cloth/texture'
  73. export default {
  74. name: 'Texture',
  75. dicts: ['sys_normal_disable'],
  76. data() {
  77. return {
  78. // 遮罩层
  79. loading: true,
  80. // 选中数组
  81. ids: [],
  82. // 非单个禁用
  83. single: true,
  84. // 非多个禁用
  85. multiple: true,
  86. // 显示搜索条件
  87. showSearch: true,
  88. // 总条数
  89. total: 0,
  90. // 衣服质地表格数据
  91. textureList: [],
  92. // 弹出层标题
  93. title: '',
  94. // 是否显示弹出层
  95. open: false,
  96. // 查询参数
  97. queryParams: {
  98. code: null,
  99. name: null,
  100. status: null
  101. },
  102. // 表单参数
  103. form: {},
  104. // 表单校验
  105. rules: {
  106. code: [{ required: true, message: '编号不能为空', trigger: 'blur' }],
  107. name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
  108. status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
  109. }
  110. }
  111. },
  112. created() {
  113. this.getList()
  114. },
  115. methods: {
  116. /** 查询衣服质地列表 */
  117. getList() {
  118. this.$nextTick(() => {
  119. this.$refs.pagination.handleSearch(true)
  120. })
  121. },
  122. // 取消按钮
  123. cancel() {
  124. this.open = false
  125. this.reset()
  126. },
  127. // 表单重置
  128. reset() {
  129. this.form = {
  130. id: null,
  131. code: null,
  132. name: null,
  133. status: '0',
  134. delFlag: null,
  135. createById: null,
  136. createBy: null,
  137. createTime: null,
  138. updateById: null,
  139. updateBy: null,
  140. updateTime: null,
  141. remark: null
  142. }
  143. this.resetForm('form')
  144. },
  145. /** 搜索按钮操作 */
  146. handleQuery() {
  147. this.getList()
  148. },
  149. /** 重置按钮操作 */
  150. resetQuery() {
  151. this.resetForm('queryForm')
  152. this.handleQuery()
  153. },
  154. // 多选框选中数据
  155. handleSelectionChange(selection) {
  156. this.ids = selection.map((item) => item.id)
  157. this.single = selection.length !== 1
  158. this.multiple = !selection.length
  159. },
  160. /** 新增按钮操作 */
  161. handleAdd() {
  162. this.reset()
  163. this.open = true
  164. this.title = '添加衣服质地'
  165. },
  166. /** 修改按钮操作 */
  167. handleUpdate(row) {
  168. this.reset()
  169. const id = row.id || this.ids
  170. getTexture(id).then((response) => {
  171. this.form = response.data
  172. this.open = true
  173. this.title = '修改衣服质地'
  174. })
  175. },
  176. /** 提交按钮 */
  177. submitForm() {
  178. this.$refs['form'].validate((valid) => {
  179. if (valid) {
  180. if (this.form.id != null) {
  181. updateTexture(this.form).then((response) => {
  182. this.$modal.msgSuccess('修改成功')
  183. this.open = false
  184. this.getList()
  185. })
  186. } else {
  187. addTexture(this.form).then((response) => {
  188. this.$modal.msgSuccess('新增成功')
  189. this.open = false
  190. this.getList()
  191. })
  192. }
  193. }
  194. })
  195. },
  196. /** 删除按钮操作 */
  197. handleDelete(row) {
  198. const ids = row.id || this.ids
  199. this.$modal
  200. .confirm('是否确认删除衣服质地编号为"' + ids + '"的数据项?')
  201. .then(function () {
  202. return delTexture(ids)
  203. })
  204. .then(() => {
  205. this.getList()
  206. this.$modal.msgSuccess('删除成功')
  207. })
  208. .catch(() => {})
  209. },
  210. /** 导出按钮操作 */
  211. handleExport() {
  212. this.download(
  213. 'cloth/texture/export',
  214. {
  215. ...this.queryParams
  216. },
  217. `texture_${new Date().getTime()}.xlsx`
  218. )
  219. },
  220. checkClose(done) {
  221. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  222. .then(function () {
  223. done()
  224. })
  225. .then(() => {})
  226. .catch(() => {})
  227. },
  228. handleStatusChange(row) {
  229. let text = row.status === '0' ? '启用' : '停用'
  230. this.$confirm('确认要' + text + ' ' + row.name + ' 吗?')
  231. .then(function () {
  232. return updateTextureStatus(row.id, row.status)
  233. })
  234. .then(() => {
  235. this.$modal.msgSuccess(text + '成功')
  236. })
  237. .catch(function () {
  238. row.status = row.status === '0' ? '1' : '0'
  239. })
  240. }
  241. }
  242. }
  243. </script>