index.vue 11 KB

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