index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="name">
  5. <el-input v-model="queryParams.name" placeholder="请输入洗衣方式名称" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  9. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-row :gutter="10" class="mb8">
  13. <el-col :span="1.5">
  14. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd" v-hasPermi="['cloth:texture:add']">新增</el-button>
  15. </el-col>
  16. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
  17. </el-row>
  18. <Page uri="/mapi/core/washMode/list" :request-params="queryParams" ref="pagination">
  19. <el-table-column type="selection" width="55" align="center" />
  20. <el-table-column label="编号" align="center" prop="id" />
  21. <el-table-column label="洗衣方式名称" align="center" prop="name" />
  22. <el-table-column label="显示顺序" align="center" prop="sort" />
  23. <el-table-column label="洗衣方式状态" align="center" prop="status">
  24. <template slot-scope="scope">
  25. <el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="创建人" align="center" prop="createBy" />
  29. <el-table-column label="创建时间" align="center" prop="createTime" />
  30. <el-table-column label="修改人" align="center" prop="updateBy" />
  31. <el-table-column label="修改时间" align="center" prop="createTime" />
  32. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  33. <template slot-scope="scope">
  34. <el-button type="text" icon="el-icon-share" @click="handleRelationUpdate(scope.row)" v-hasPermi="['cloth:washMode:add']">关联类别</el-button>
  35. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['cloth:washMode:edit']">修改</el-button>
  36. <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['cloth:washMode:remove']">删除</el-button>
  37. </template>
  38. </el-table-column>
  39. </Page>
  40. <!-- 添加或修改洗衣方式对话框 -->
  41. <el-dialog :title="title" :visible.sync="open" direction="rtl" size="30%" append-to-body destroy-on-close>
  42. <el-row :gutter="15">
  43. <el-form ref="form" :model="form" :rules="rules" size="medium" label-width="100px">
  44. <el-form-item label="洗衣方式" prop="name">
  45. <el-input v-model="form.name" placeholder="请输入洗衣方式名称" />
  46. </el-form-item>
  47. <el-form-item label="显示顺序" prop="sort">
  48. <el-input-number v-model="form.sort" placeholder="请输入显示顺序(升序排列显示)" :min="0" :step-strictly="true" :style="{ width: '100%' }"> </el-input-number>
  49. </el-form-item>
  50. <el-form-item label="状态" prop="status">
  51. <el-radio-group v-model="form.status" size="small">
  52. <el-radio-button v-for="dict in dict.type.sys_normal_disable" :label="dict.value" :key="dict.value">{{ dict.label }}</el-radio-button>
  53. </el-radio-group>
  54. </el-form-item>
  55. </el-form>
  56. </el-row>
  57. <div slot="footer" class="dialog-footer">
  58. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  59. <el-button @click="closeDialog">取 消</el-button>
  60. </div>
  61. </el-dialog>
  62. <!-- 洗衣方式关联类别对话框 -->
  63. <el-dialog :title="title" :visible.sync="relationOpen" direction="rtl" size="30%" append-to-body destroy-on-close>
  64. <el-form>
  65. <el-form-item>
  66. <div style="margin-left: 30px">
  67. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
  68. <div style="margin-top: 20px"></div>
  69. <el-checkbox-group v-model="selectClothTypeList" @change="handleCheckedClothTypeChange">
  70. <el-checkbox v-for="item in allClothTypeList" style="height: 50px" :label="item.id" :key="item.id + ''">{{ item.name }}</el-checkbox>
  71. </el-checkbox-group>
  72. </div>
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="primary" @click="submitRelationForm" style="margin-left: 5%">提交</el-button>
  77. <el-button @click="closeRelationDialog">取 消</el-button>
  78. </div>
  79. </el-dialog>
  80. </div>
  81. </template>
  82. <script>
  83. import { listWashMode, getWashMode, delWashMode, addWashMode, updateWashMode, changeWashModeStatus, addWashModeAndTypeRelation, getRelationInfo } from '@/api/core/washMode'
  84. import { listType } from '@/api/core/clothType'
  85. export default {
  86. name: 'WashMode',
  87. dicts: ['sys_normal_disable'],
  88. data() {
  89. return {
  90. checkAll: false,
  91. isIndeterminate: false,
  92. // 已选的衣服类别
  93. selectClothTypeList: [],
  94. // 全量 衣服类别
  95. allClothTypeList: [],
  96. washModeId: null,
  97. // 遮罩层
  98. loading: true,
  99. // 选中数组
  100. ids: [],
  101. // 非单个禁用
  102. single: true,
  103. // 非多个禁用
  104. multiple: true,
  105. // 显示搜索条件
  106. showSearch: true,
  107. // 总条数
  108. total: 0,
  109. // 洗衣方式表格数据
  110. washModeList: [],
  111. // 弹出层标题
  112. title: '',
  113. // 是否显示弹出层
  114. open: false,
  115. relationOpen: false,
  116. // 查询参数
  117. queryParams: {
  118. name: null,
  119. sort: null,
  120. status: null,
  121. createById: null,
  122. updateById: null
  123. },
  124. queryParams2: {
  125. pageNum: 1,
  126. pageSize: 9999
  127. },
  128. // 表单参数
  129. form: {},
  130. relationForm: {},
  131. relationRules: {},
  132. // 表单校验
  133. rules: {
  134. name: [
  135. {
  136. required: true,
  137. message: '洗衣方式名称不能为空',
  138. trigger: 'blur'
  139. }
  140. ]
  141. }
  142. }
  143. },
  144. created() {
  145. this.getClothTypeList()
  146. this.getList()
  147. },
  148. methods: {
  149. getClothTypeList() {
  150. listType(this.queryParams2).then((response) => {
  151. this.allClothTypeList = response.rows
  152. })
  153. },
  154. /** 查询洗衣方式列表 */
  155. getList() {
  156. this.$nextTick(() => {
  157. this.$refs.pagination.handleSearch(true)
  158. })
  159. },
  160. // 取消按钮
  161. cancel() {
  162. this.open = false
  163. this.reset()
  164. },
  165. // 表单重置
  166. reset() {
  167. this.form = {
  168. id: null,
  169. name: null,
  170. sort: null,
  171. status: '0',
  172. delFlag: null,
  173. createBy: null,
  174. createById: null,
  175. createTime: null,
  176. updateBy: null,
  177. updateById: null,
  178. updateTime: null,
  179. remark: null
  180. }
  181. this.resetForm('form')
  182. },
  183. /** 搜索按钮操作 */
  184. handleQuery() {
  185. this.getList()
  186. },
  187. /** 重置按钮操作 */
  188. resetQuery() {
  189. this.resetForm('queryForm')
  190. this.handleQuery()
  191. },
  192. /** 新增按钮操作 */
  193. handleAdd() {
  194. this.reset()
  195. this.open = true
  196. this.title = '添加洗衣方式'
  197. },
  198. /** 修改按钮操作 */
  199. handleUpdate(row) {
  200. this.reset()
  201. const id = row.id || this.ids
  202. getWashMode(id).then((response) => {
  203. this.form = response.data
  204. this.open = true
  205. this.title = '修改洗衣方式'
  206. })
  207. },
  208. /** 关联按钮操作 */
  209. handleRelationUpdate(row) {
  210. this.selectClothTypeList = []
  211. this.washModeId = row.id
  212. getRelationInfo(this.washModeId).then((response) => {
  213. this.selectClothTypeList = response.data
  214. this.handleCheckedClothTypeChange(this.selectClothTypeList)
  215. this.relationOpen = true
  216. this.title = '洗衣方式关联类别'
  217. })
  218. },
  219. /** 提交按钮 */
  220. submitForm() {
  221. this.$refs['form'].validate((valid) => {
  222. if (valid) {
  223. if (this.form.id != null) {
  224. updateWashMode(this.form).then((response) => {
  225. this.$modal.msgSuccess('修改成功')
  226. this.open = false
  227. this.getList()
  228. })
  229. } else {
  230. addWashMode(this.form).then((response) => {
  231. this.$modal.msgSuccess('新增成功')
  232. this.open = false
  233. this.getList()
  234. })
  235. }
  236. }
  237. })
  238. },
  239. /** 关联页面提交按钮 */
  240. submitRelationForm() {
  241. this.relationForm.washModeId = this.washModeId
  242. this.relationForm.clothTypeIdList = this.selectClothTypeList
  243. addWashModeAndTypeRelation(this.relationForm).then((response) => {
  244. this.$modal.msgSuccess('修改成功')
  245. this.relationOpen = false
  246. this.getList()
  247. })
  248. },
  249. // 多选框选中数据
  250. handleSelectionChange(selection) {
  251. this.ids = selection.map((item) => item.id)
  252. this.single = selection.length !== 1
  253. this.multiple = !selection.length
  254. },
  255. /** 删除按钮操作 */
  256. handleDelete(row) {
  257. const ids = row.id || this.ids
  258. this.$modal
  259. .confirm('是否确认删除编号为"' + ids + '"的数据项?')
  260. .then(function () {
  261. return delWashMode(ids)
  262. })
  263. .then(() => {
  264. this.getList()
  265. this.$modal.msgSuccess('删除成功')
  266. })
  267. .catch(() => {})
  268. },
  269. // 洗衣方式状态修改
  270. handleStatusChange(row) {
  271. let text = row.status === '0' ? '启用' : '停用'
  272. this.$modal
  273. .confirm('确认要' + text + ' ' + row.name + ' 吗?')
  274. .then(function () {
  275. return changeWashModeStatus(row.id, row.status)
  276. })
  277. .then(() => {
  278. this.$modal.msgSuccess(text + '成功')
  279. })
  280. .catch(function () {
  281. row.status = row.status === '0' ? '1' : '0'
  282. })
  283. },
  284. checkClose(done) {
  285. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  286. .then(function () {
  287. done()
  288. })
  289. .then(() => {})
  290. .catch(() => {})
  291. },
  292. closeDialog() {
  293. this.open = false
  294. },
  295. closeRelationDialog() {
  296. this.relationOpen = false
  297. },
  298. handleCheckAllChange(val) {
  299. let ids = this.allClothTypeList.map((item) => item.id)
  300. this.selectClothTypeList = val ? ids : []
  301. console.log(this.selectClothTypeList)
  302. this.isIndeterminate = false
  303. },
  304. handleCheckedClothTypeChange(value) {
  305. let checkedCount = value.length
  306. this.checkAll = checkedCount === this.allClothTypeList.length
  307. this.isIndeterminate = checkedCount > 0 && checkedCount < this.allClothTypeList.length
  308. }
  309. }
  310. }
  311. </script>