index.vue 11 KB

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