index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :columnParsing="columnParsing"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :tableAttributes="tableAttributes"
  8. :tableEvents="tableEvents"
  9. :operation="operation()"
  10. >
  11. <div class="cartographer_big">
  12. <el-dialog title="配置" width="100%" :modal="false" :visible.sync="formBool" :before-close="handleClose">
  13. <zj-page-container v-if="formBool">
  14. <zj-page-fill class="neibuview">
  15. <zj-form-container
  16. ref="formRef"
  17. :form-data="formData"
  18. :form-rules="formRules"
  19. :form-attributes="{ size: 'mini' }"
  20. >
  21. <zj-form-module title="基本项" label-width="150px" :form-data="formData" :form-items="items" />
  22. <zj-form-module
  23. v-if="!($route.name == 'website-refund-config' && formType == 0)"
  24. title="销售价格倍率"
  25. label-width="150px"
  26. :form-data="formData"
  27. :form-items="items2"
  28. />
  29. </zj-form-container>
  30. </zj-page-fill>
  31. <!-- 操作按钮 -->
  32. <div style="box-sizing: border-box; padding: 10px; text-align: right">
  33. <el-button size="mini" @click="handleClose">取 消</el-button>
  34. <el-button v-if="~[0, 1].indexOf(formType)" size="mini" @click="formConfirm" type="primary"
  35. >确 定</el-button
  36. >
  37. </div>
  38. </zj-page-container>
  39. </el-dialog>
  40. </div>
  41. </template-page>
  42. </template>
  43. <script>
  44. import TemplatePage from '@/components/template/template-page-1.vue'
  45. import import_mixin from '@/components/template/import_mixin.js'
  46. import {
  47. partsRefundConfigList,
  48. partsRefundConfigAdd,
  49. partsRefundConfigEdit,
  50. partsRefundConfigBatchDel,
  51. partsRefundConfigDetail,
  52. partsRefundConfigGetDefault
  53. } from '@/api/parts-config'
  54. import operation_mixin from '@/components/template/operation_mixin.js'
  55. import { required, requiredValueMin } from '@/components/template/rules_verify.js'
  56. import { getWebsit } from '@/api/customerManagement.js'
  57. export default {
  58. components: { TemplatePage },
  59. mixins: [import_mixin, operation_mixin],
  60. data() {
  61. return {
  62. // 表格属性
  63. tableAttributes: {
  64. selectColumn: false
  65. },
  66. // 表格事件
  67. tableEvents: {
  68. 'selection-change': this.selectionChange
  69. },
  70. recordSelected: [],
  71. formBool: false,
  72. formType: 0,
  73. formData: {
  74. companyWechatId: '',
  75. companyWechatName: '',
  76. isDefault: false,
  77. newRefundInner: 0,
  78. newRefundOutside: 0,
  79. oldRefund: 0,
  80. priceRate1: 0,
  81. priceRate2: 0,
  82. priceRate3: 0,
  83. websitId: '',
  84. websitName: ''
  85. },
  86. formRules: {},
  87. websitList: []
  88. }
  89. },
  90. computed: {
  91. optionsEvensGroup() {
  92. return [
  93. [
  94. [
  95. this.optionsEvensAuth('add', {
  96. click: () => {
  97. getWebsit({ type: 'C', status: true, queryPartsWebsit: true }).then(res => {
  98. this.websitList = res.data
  99. this.formType = 0
  100. this.formBool = true
  101. })
  102. }
  103. })
  104. ],
  105. [
  106. this.optionsEvensAuth('defaultConfig', {
  107. click: () => {
  108. getWebsit({ type: 'C', status: true, queryPartsWebsit: true }).then(res => {
  109. this.websitList = res.data
  110. this.formType = this.$route.name == 'website-refund-config' ? 2 : 1
  111. partsRefundConfigGetDefault().then(res => {
  112. this.formData = res.data
  113. this.$nextTick(() => {
  114. this.formBool = true
  115. })
  116. })
  117. })
  118. }
  119. })
  120. ]
  121. ]
  122. ]
  123. },
  124. items() {
  125. return [
  126. {
  127. isShow: !this.formData.isDefault || this.$route.name == 'website-refund-config',
  128. name: 'el-select',
  129. md: 8,
  130. options: this.websitList.map(item => ({ label: item.name, value: item.websitId })),
  131. attributes: {
  132. clearable: true,
  133. filterable: true,
  134. disabled: this.formType === 2,
  135. placeholder: '请输入'
  136. },
  137. formItemAttributes: {
  138. label: '配置网点',
  139. prop: 'websitId',
  140. rules: this.formData.isDefault ? [] : [...required]
  141. },
  142. events: {
  143. change: val => {
  144. var data = this.websitList.find(item => item.websitId === val)
  145. this.formData.websitName = data?.websitName || ''
  146. }
  147. }
  148. },
  149. {
  150. isShow: !this.formData.isDefault || this.$route.name == 'website-refund-config',
  151. name: 'slot-component',
  152. md: 16,
  153. attributes: {},
  154. formItemAttributes: {
  155. label: '',
  156. prop: '',
  157. 'label-width': '0px'
  158. },
  159. render: (h, { props, onInput }) => {
  160. return <div></div>
  161. }
  162. },
  163. {
  164. name: 'el-input',
  165. md: 8,
  166. attributes: {
  167. disabled: this.formType === 2,
  168. placeholder: '请输入',
  169. type: 'number',
  170. min: 1
  171. },
  172. formItemAttributes: {
  173. label: '新件返还(市区)',
  174. prop: 'newRefundInner',
  175. rules: [...required]
  176. }
  177. },
  178. {
  179. name: 'slot-component',
  180. md: 16,
  181. attributes: {},
  182. formItemAttributes: {
  183. label: '',
  184. prop: '',
  185. 'label-width': '0px'
  186. },
  187. render: (h, { props, onInput }) => {
  188. return <div>天内返还不使用的新件</div>
  189. }
  190. },
  191. {
  192. name: 'el-input',
  193. md: 8,
  194. attributes: {
  195. disabled: this.formType === 2,
  196. placeholder: '请输入',
  197. type: 'number',
  198. min: 1
  199. },
  200. formItemAttributes: {
  201. label: '新件返还(外区)',
  202. prop: 'newRefundOutside',
  203. rules: [...required]
  204. }
  205. },
  206. {
  207. name: 'slot-component',
  208. md: 16,
  209. attributes: {},
  210. formItemAttributes: {
  211. label: '',
  212. prop: '',
  213. 'label-width': '0px'
  214. },
  215. render: (h, { props, onInput }) => {
  216. return <div>天内返还不使用的新件</div>
  217. }
  218. },
  219. {
  220. name: 'el-input',
  221. md: 8,
  222. attributes: {
  223. disabled: this.formType === 2,
  224. placeholder: '请输入',
  225. type: 'number',
  226. min: 1
  227. },
  228. formItemAttributes: {
  229. label: '旧件返还',
  230. prop: 'oldRefund',
  231. rules: [...required]
  232. }
  233. },
  234. {
  235. name: 'slot-component',
  236. md: 16,
  237. attributes: {},
  238. formItemAttributes: {
  239. label: '',
  240. prop: '',
  241. 'label-width': '0px'
  242. },
  243. render: (h, { props, onInput }) => {
  244. return <div>天内返维修完工时替换的旧件</div>
  245. }
  246. }
  247. ]
  248. },
  249. items2() {
  250. return [
  251. {
  252. name: 'el-input',
  253. md: 8,
  254. attributes: {
  255. disabled: this.formType === 2 || this.$route.name == 'website-refund-config',
  256. placeholder: '请输入',
  257. type: 'number',
  258. min: 1
  259. },
  260. formItemAttributes: {
  261. label: '空调',
  262. prop: 'priceRate1',
  263. rules: this.$route.name == 'website-refund-config' ? [] : requiredValueMin(1)
  264. }
  265. },
  266. {
  267. name: 'slot-component',
  268. md: 16,
  269. attributes: {},
  270. formItemAttributes: {
  271. label: '',
  272. prop: '',
  273. 'label-width': '0px'
  274. },
  275. render: (h, { props, onInput }) => {
  276. return <div>销售价格倍率设置,注需要大于等于 1</div>
  277. }
  278. },
  279. {
  280. name: 'el-input',
  281. md: 8,
  282. attributes: {
  283. disabled: this.formType === 2 || this.$route.name == 'website-refund-config',
  284. placeholder: '请输入',
  285. type: 'number',
  286. min: 1
  287. },
  288. formItemAttributes: {
  289. label: '生活电器',
  290. prop: 'priceRate3',
  291. rules: this.$route.name == 'website-refund-config' ? [] : requiredValueMin(1)
  292. }
  293. },
  294. {
  295. name: 'slot-component',
  296. md: 16,
  297. attributes: {},
  298. formItemAttributes: {
  299. label: '',
  300. prop: '',
  301. 'label-width': '0px'
  302. },
  303. render: (h, { props, onInput }) => {
  304. return <div>销售价格倍率设置,注需要大于等于 1</div>
  305. }
  306. },
  307. {
  308. name: 'el-input',
  309. md: 8,
  310. attributes: {
  311. disabled: this.formType === 2 || this.$route.name == 'website-refund-config',
  312. placeholder: '请输入',
  313. type: 'number',
  314. min: 1
  315. },
  316. formItemAttributes: {
  317. label: '冰箱',
  318. prop: 'priceRate2',
  319. rules: this.$route.name == 'website-refund-config' ? [] : requiredValueMin(1)
  320. }
  321. },
  322. {
  323. name: 'slot-component',
  324. md: 16,
  325. attributes: {},
  326. formItemAttributes: {
  327. label: '',
  328. prop: '',
  329. 'label-width': '0px'
  330. },
  331. render: (h, { props, onInput }) => {
  332. return <div>销售价格倍率设置,注需要大于等于 1</div>
  333. }
  334. }
  335. ]
  336. }
  337. },
  338. methods: {
  339. // 列表请求函数
  340. getList: partsRefundConfigList,
  341. // 表格列解析渲染数据更改
  342. columnParsing(item, defaultData) {
  343. return defaultData
  344. },
  345. // 获取勾选框数据
  346. selectionChange(data) {
  347. this.recordSelected = data
  348. },
  349. handleClose() {
  350. this.$refs?.pageRef?.refreshList()
  351. this.$data.formData = this.$options.data().formData
  352. this.formType = 0
  353. this.formBool = false
  354. },
  355. formConfirm() {
  356. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  357. if (valid) {
  358. ;(this.formData.id ? partsRefundConfigEdit : partsRefundConfigAdd)(this.formData).then(res => {
  359. this.$message({ type: 'success', message: '配置成功!' })
  360. this.$refs.pageRef.refreshList()
  361. this.handleClose()
  362. })
  363. }
  364. })
  365. },
  366. operation() {
  367. return this.operationBtn({
  368. view: {
  369. click: ({ row, index, column }) => {
  370. getWebsit({ type: 'C', status: true, queryPartsWebsit: true }).then(res => {
  371. this.websitList = res.data
  372. })
  373. partsRefundConfigDetail({
  374. id: row.id
  375. }).then(res => {
  376. this.formData = res.data
  377. this.$nextTick(() => {
  378. this.formType = 2
  379. this.formBool = true
  380. })
  381. })
  382. }
  383. },
  384. edit: {
  385. click: ({ row, index, column }) => {
  386. getWebsit({ type: 'C', status: true, queryPartsWebsit: true }).then(res => {
  387. this.websitList = res.data
  388. })
  389. partsRefundConfigDetail({
  390. id: row.id
  391. }).then(res => {
  392. this.formData = res.data
  393. this.$nextTick(() => {
  394. this.formType = 1
  395. this.formBool = true
  396. })
  397. })
  398. }
  399. },
  400. del: {
  401. prompt: '确定删除吗?',
  402. click: ({ row, index, column }) => {
  403. partsRefundConfigBatchDel([row.id]).then(res => {
  404. this.$message({ type: 'success', message: '删除成功!' })
  405. this.$refs.pageRef.refreshList()
  406. })
  407. }
  408. }
  409. })
  410. }
  411. }
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. .neibuview {
  416. box-sizing: border-box;
  417. padding-left: 16px;
  418. ::v-deep & > .zj-page-fill-scroll {
  419. box-sizing: border-box;
  420. padding-right: 16px;
  421. & > div:nth-child(1) {
  422. margin-top: 20px;
  423. }
  424. }
  425. }
  426. </style>