index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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="title">
  5. <el-input v-model="queryParams.title" 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="['activity:recharge:add']">新增</el-button>
  15. </el-col>
  16. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  17. </el-row>
  18. <Page uri="/mapi/activity/recharge/list" :request-params="queryParams" ref="pagination">
  19. <el-table-column label="编号" align="center" prop="id" width="80" />
  20. <el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true" width="250" />
  21. <el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" />
  22. <el-table-column label="宣传图片" align="center" prop="imgUrl" width="100">
  23. <template slot-scope="scope">
  24. <image-preview :src="scope.row.imgUrl" :width="50" :height="50" />
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="状态" align="center" prop="status" width="150">
  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="startDate" width="180">
  33. <template slot-scope="scope">
  34. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="结束时间" align="center" prop="endDate" width="180">
  38. <template slot-scope="scope">
  39. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="适用门店" align="center" prop="storeNum">
  43. <template slot-scope="scope">
  44. <el-button type="text" @click="handleUpdate(scope.row)">{{ scope.row.storeNum }}家门店</el-button>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
  48. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="300">
  49. <template slot-scope="scope">
  50. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['activity:recharge:edit']">修改</el-button>
  51. <el-button type="text" icon="el-icon-s-shop" @click="handleSetRechargeItems(scope.row)" v-hasPermi="['activity:recharge:list']">设置充值规则</el-button>
  52. <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['activity:recharge:remove']">删除</el-button>
  53. </template>
  54. </el-table-column>
  55. </Page>
  56. <!-- 添加或修改活动明细对话框 -->
  57. <el-dialog :title="title" :visible.sync="open" size="50%" append-to-body>
  58. <el-row :gutter="15">
  59. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  60. <el-col :span="24">
  61. <el-form-item label="标题" prop="title">
  62. <el-input v-model="form.title" placeholder="请输入标题" maxlength="200" show-word-limit />
  63. </el-form-item>
  64. <el-form-item label="描述" prop="description">
  65. <el-input v-model="form.description" type="textarea" placeholder="请输入描述" maxlength="500" show-word-limit />
  66. </el-form-item>
  67. <el-form-item label="宣传图片">
  68. <image-upload v-model="form.imgUrl" />
  69. </el-form-item>
  70. <el-form-item label="内容">
  71. <editor v-model="form.content" :min-height="192" />
  72. </el-form-item>
  73. <el-form-item label="有效期" prop="duringDate">
  74. <el-date-picker v-model="form.duringDate" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="24">
  78. <el-form-item label="适用门店" prop="selectStoreIds">
  79. <el-transfer v-model="form.selectStoreIds" :data="form.storeVOS" filterable="true" :titles="['待选择的门店', '已选择的门店']"></el-transfer>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="24">
  83. <el-form-item label="状态" prop="status">
  84. <el-radio-group v-model="form.status">
  85. <el-radio-button v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
  86. </el-radio-group>
  87. </el-form-item>
  88. </el-col>
  89. </el-form>
  90. </el-row>
  91. <div slot="footer" class="dialog-footer">
  92. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  93. <el-button @click="cancel">取 消</el-button>
  94. </div>
  95. </el-dialog>
  96. </div>
  97. </template>
  98. <script>
  99. import { listInfo, getInfo, delInfo, addInfo, updateInfo, updateInfoStatus } from '@/api/activity/rechargeInfo'
  100. export default {
  101. name: 'RechargeInfo',
  102. dicts: ['activity_user_scope', 'activity_type', 'activity_pay_scope', 'sys_normal_disable'],
  103. data() {
  104. return {
  105. // 遮罩层
  106. loading: true,
  107. // 选中数组
  108. ids: [],
  109. // 非单个禁用
  110. single: true,
  111. // 非多个禁用
  112. multiple: true,
  113. // 显示搜索条件
  114. showSearch: true,
  115. // 总条数
  116. total: 0,
  117. // 活动明细表格数据
  118. infoList: [],
  119. // 弹出层标题
  120. title: '',
  121. // 是否显示弹出层
  122. open: false,
  123. // 查询参数
  124. queryParams: {
  125. title: null,
  126. activityType: null
  127. },
  128. // 表单参数
  129. form: {
  130. duringDate: [],
  131. status: '0'
  132. },
  133. // 表单校验
  134. rules: {
  135. title: [{ required: true, message: '标题不能为空', trigger: 'blur' }],
  136. description: [{ required: true, message: '描述不能为空', trigger: 'blur' }],
  137. imgUrl: [{ required: true, message: '宣传图片不能为空', trigger: 'blur' }],
  138. content: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
  139. duringDate: [{ required: true, message: '有效期不能为空', trigger: 'blur' }],
  140. activityType: [{ required: true, message: '活动类型不能为空', trigger: 'change' }],
  141. status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
  142. }
  143. }
  144. },
  145. created() {
  146. this.getList()
  147. },
  148. methods: {
  149. /** 查询活动明细列表 */
  150. getList() {
  151. this.$nextTick(() => {
  152. this.$refs.pagination.handleSearch(true)
  153. })
  154. },
  155. // 取消按钮
  156. cancel() {
  157. this.open = false
  158. this.reset()
  159. },
  160. // 表单重置
  161. reset() {
  162. this.form = {
  163. id: null,
  164. title: null,
  165. description: null,
  166. imgUrl: null,
  167. content: null,
  168. duringDate: [],
  169. activityType: null,
  170. delFlag: null,
  171. createById: null,
  172. createBy: null,
  173. createTime: null,
  174. updateById: null,
  175. updateBy: null,
  176. updateTime: null,
  177. remark: null,
  178. status: '0'
  179. }
  180. this.resetForm('form')
  181. },
  182. /** 搜索按钮操作 */
  183. handleQuery() {
  184. this.getList()
  185. },
  186. /** 重置按钮操作 */
  187. resetQuery() {
  188. this.resetForm('queryForm')
  189. this.handleQuery()
  190. },
  191. // 多选框选中数据
  192. handleSelectionChange(selection) {
  193. this.ids = selection.map((item) => item.id)
  194. this.single = selection.length !== 1
  195. this.multiple = !selection.length
  196. },
  197. /** 新增按钮操作 */
  198. handleAdd() {
  199. this.reset()
  200. getInfo().then((response) => {
  201. var duringDate = []
  202. response.data.duringDate = duringDate
  203. response.data.status = '0'
  204. this.form = response.data
  205. this.open = true
  206. this.title = '添加活动明细'
  207. })
  208. },
  209. /** 修改按钮操作 */
  210. handleUpdate(row) {
  211. this.reset()
  212. const id = row.id || this.ids
  213. getInfo(id).then((response) => {
  214. var duringDate = []
  215. duringDate.push(response.data.startDate)
  216. duringDate.push(response.data.endDate)
  217. response.data.duringDate = duringDate
  218. this.form = response.data
  219. this.open = true
  220. this.title = '修改活动明细'
  221. })
  222. },
  223. /** 提交按钮 */
  224. submitForm() {
  225. if (null != this.form.duringDate && this.form.duringDate.length > 0) {
  226. this.form['startDate'] = this.form.duringDate[0]
  227. this.form['endDate'] = this.form.duringDate[1]
  228. } else {
  229. delete this.form.startDate
  230. delete this.form.endDate
  231. }
  232. this.$refs['form'].validate((valid) => {
  233. if (valid) {
  234. if (this.form.id != null) {
  235. updateInfo(this.form).then((response) => {
  236. this.$modal.msgSuccess('修改成功')
  237. this.open = false
  238. this.getList()
  239. })
  240. } else {
  241. addInfo(this.form).then((response) => {
  242. this.$modal.msgSuccess('新增成功')
  243. this.open = false
  244. this.getList()
  245. })
  246. }
  247. }
  248. })
  249. },
  250. /** 删除按钮操作 */
  251. handleDelete(row) {
  252. const ids = row.id || this.ids
  253. this.$modal
  254. .confirm('是否确认删除活动明细编号为"' + ids + '"的数据项?')
  255. .then(function () {
  256. return delInfo(ids)
  257. })
  258. .then(() => {
  259. this.getList()
  260. this.$modal.msgSuccess('删除成功')
  261. })
  262. .catch(() => {})
  263. },
  264. /** 导出按钮操作 */
  265. handleExport() {
  266. this.download(
  267. 'mapi/activity/recharge/export',
  268. {
  269. ...this.queryParams
  270. },
  271. `info_${new Date().getTime()}.xlsx`
  272. )
  273. },
  274. checkClose(done) {
  275. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  276. .then(function () {
  277. done()
  278. })
  279. .then(() => {})
  280. .catch(() => {})
  281. },
  282. handleStatusChange(row) {
  283. let text = row.status === '0' ? '启用' : '停用'
  284. this.$confirm('确认要' + text + ' ' + row.name + ' 吗?')
  285. .then(function () {
  286. return updateInfoStatus(row.id, row.status)
  287. })
  288. .then(() => {
  289. this.$modal.msgSuccess(text + '成功')
  290. })
  291. .catch(function () {
  292. row.status = row.status === '0' ? '1' : '0'
  293. })
  294. },
  295. handleSetRechargeItems(row) {
  296. this.$tab.openPage(row.title + '的充值规则', '/activity/rechargeItem/' + row.id)
  297. }
  298. }
  299. }
  300. </script>