index.vue 11 KB

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