index.vue 9.3 KB

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