index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation()" :exportList="exportList">
  5. <el-dialog title="" width="860px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
  6. :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
  7. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  8. <zj-form-module :title="formDialogTitles[formDialogType]" label-width="120px" :showPackUp="false"
  9. :form-data="formData" :form-items="formItems">
  10. </zj-form-module>
  11. </zj-form-container>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button size="mini" @click="formCancel">取 消</el-button>
  14. <el-button size="mini" @click="formConfirm" type="primary">确 定</el-button>
  15. </div>
  16. </el-dialog>
  17. </template-page>
  18. </template>
  19. <script>
  20. import TemplatePage from '@/components/template/template-page-1.vue'
  21. import import_mixin from '@/components/template/import_mixin.js'
  22. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  23. import { materialNormList, materialNormListExport, materialNormAdd, materialNormEdit, materialNormDetail, materialNormBatchUpdateStatus, materialNormImport2, materialNormImport } from "@/api/auxiliaryChargeManagement";
  24. import { materialCategoryTree } from "@/api/auxiliaryMaterialClass";
  25. import { getTypeList } from "@/api/auxiliaryFittings/attachmentProfile";
  26. import { commonTemplateDownload } from '@/api/common.js'
  27. import operation_mixin from '@/components/template/operation_mixin.js'
  28. export default {
  29. components: { TemplatePage },
  30. mixins: [import_mixin, operation_mixin],
  31. data() {
  32. return {
  33. // 表格属性
  34. tableAttributes: {
  35. // 启用勾选列
  36. selectColumn: true
  37. },
  38. // 表格事件
  39. tableEvents: {
  40. 'selection-change': this.selectionChange
  41. },
  42. // 勾选选中行
  43. recordSelected: [],
  44. /** 表单变量 */
  45. formDialogType: 0,
  46. formDialogTitles: ["新增", "编辑"],
  47. formDialog: false,
  48. formData: {
  49. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  50. "categoryId": "",
  51. "companyWechatId": "",
  52. "createBy": "",
  53. "createTime": "",
  54. "normAmount": 0,
  55. "normCode": "",
  56. "normId": "",
  57. "normName": "",
  58. "normType": "",
  59. "outWebsitAmount": 0,
  60. "outWorkerAmount": 0,
  61. "parentCategoryId": "",
  62. "remark": "",
  63. "selfWebsitAmount": 0,
  64. "selfWorkerAmount": 0,
  65. "specification": "",
  66. "status": "ON",
  67. "unit": "",
  68. },
  69. partsUnitList: [],
  70. materialCategoryTree: []
  71. }
  72. },
  73. computed: {
  74. // 事件组合
  75. optionsEvensGroup() {
  76. return [
  77. [
  78. [
  79. this.optionsEvensAuth("add", {
  80. click: this.addData
  81. }),
  82. ],
  83. [
  84. this.optionsEvensAuth(["imp", "template"], {
  85. name: '导入物料',
  86. click: () => { }
  87. }),
  88. this.optionsEvensAuth("imp", ({ moduleName }) => {
  89. return {
  90. name: moduleName,
  91. render: () => {
  92. return this.importButton(materialNormImport, moduleName)
  93. }
  94. }
  95. }),
  96. this.optionsEvensAuth("template", {
  97. click: () => {
  98. commonTemplateDownload({ name: '辅材收费标准模板(物料收费).xlsx' }, `辅材收费标准模板(物料收费)`)
  99. .then(res => {
  100. this.$message({
  101. message: '下载成功',
  102. type: 'success'
  103. })
  104. })
  105. .catch(err => {
  106. this.$message.error('下载失败')
  107. })
  108. }
  109. }),
  110. ],
  111. [
  112. this.optionsEvensAuth(["Import", "downloadTemplate"], {
  113. name: '导入服务',
  114. click: () => { }
  115. }),
  116. this.optionsEvensAuth("Import", ({ moduleName }) => {
  117. return {
  118. name: moduleName,
  119. render: () => {
  120. return this.importButton(materialNormImport2, moduleName)
  121. }
  122. }
  123. }),
  124. this.optionsEvensAuth("downloadTemplate", {
  125. click: () => {
  126. commonTemplateDownload({ name: '辅材收费标准模板(服务收费).xlsx' }, `辅材收费标准模板(服务收费)`)
  127. .then(res => {
  128. this.$message({
  129. message: '下载成功',
  130. type: 'success'
  131. })
  132. })
  133. .catch(err => {
  134. this.$message.error('下载失败')
  135. })
  136. }
  137. }),
  138. ],
  139. ],
  140. [
  141. [
  142. this.optionsEvensAuth("batchLaunch", {
  143. click: () => {
  144. if (this.recordSelected.length) {
  145. this.setRowStatus("ON")
  146. } else {
  147. this.$message({
  148. type: 'warning',
  149. message: `请先勾选需要设置的数据!`,
  150. });
  151. }
  152. }
  153. }),
  154. ],
  155. [
  156. this.optionsEvensAuth("batchRemoval", {
  157. click: () => {
  158. if (this.recordSelected.length) {
  159. this.setRowStatus("OFF")
  160. } else {
  161. this.$message({
  162. type: 'warning',
  163. message: `请先勾选需要设置的数据!`,
  164. });
  165. }
  166. }
  167. }),
  168. ]
  169. ]
  170. ]
  171. },
  172. // 更多参数
  173. moreParameters() {
  174. return []
  175. },
  176. formItems() {
  177. return [{
  178. md: 12,
  179. isShow: true,
  180. name: 'el-input',
  181. attributes: { placeholder: '请输入', disabled: true },
  182. formItemAttributes: {
  183. label: '所属商户',
  184. prop: 'companyWechatName',
  185. rules: [...required]
  186. }
  187. }, {
  188. md: 12,
  189. isShow: true,
  190. name: 'el-radio',
  191. options: [{ label: "上架", value: "ON" }, { label: "下架", value: "OFF" }],
  192. attributes: {},
  193. formItemAttributes: {
  194. label: '状态',
  195. prop: 'status',
  196. rules: [...required]
  197. },
  198. }, {
  199. md: 12,
  200. isShow: true,
  201. name: 'el-cascader',
  202. attributes: { style: "width:100%", placeholder: '请输入', options: this.materialCategoryTree, 'show-all-levels': false, props: { value: "categoryId", label: "categoryName", children: "child", emitPath: false }, clearable: true },
  203. formItemAttributes: {
  204. label: '选择分类',
  205. prop: 'categoryId',
  206. rules: [...required]
  207. }
  208. }, {
  209. md: 12,
  210. isShow: true,
  211. name: 'el-input',
  212. attributes: { placeholder: '请输入' },
  213. formItemAttributes: {
  214. label: '辅材名称',
  215. prop: 'normName',
  216. rules: [...required]
  217. }
  218. }, {
  219. md: 12,
  220. isShow: true,
  221. name: 'el-select-add',
  222. labelKey: 'dictValue',
  223. valueKey: 'dictValue',
  224. options: this.partsUnitList,
  225. attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
  226. formItemAttributes: {
  227. label: '单位',
  228. prop: 'unit',
  229. rules: [...required]
  230. }
  231. }, {
  232. md: 12,
  233. isShow: true,
  234. name: 'el-input',
  235. attributes: { placeholder: '请输入' },
  236. formItemAttributes: {
  237. label: '商品代码',
  238. prop: 'normCode',
  239. rules: []
  240. }
  241. }, {
  242. md: 12,
  243. isShow: true,
  244. name: 'el-input',
  245. attributes: { placeholder: '请输入' },
  246. formItemAttributes: {
  247. label: '规格型号',
  248. prop: 'specification',
  249. rules: []
  250. }
  251. }, {
  252. md: 12,
  253. isShow: true,
  254. name: 'el-radio',
  255. options: [{ label: "物料收费", value: "M" }, { label: "服务收费", value: "S" }],
  256. attributes: {},
  257. formItemAttributes: {
  258. label: '收费类型',
  259. prop: 'normType',
  260. rules: [...required]
  261. },
  262. }, {
  263. md: 12,
  264. isShow: true,
  265. name: 'el-input',
  266. attributes: { placeholder: '请输入', type: "number" },
  267. formItemAttributes: {
  268. label: '收费标准',
  269. prop: 'normAmount',
  270. rules: [...required]
  271. },
  272. events: {
  273. input: (val) => {
  274. this.formData.selfWorkerAmount = ""
  275. this.formData.outWorkerAmount = ""
  276. this.$nextTick(() => {
  277. this.formData.selfWebsitAmount = this.setNumber(
  278. this.formData.normAmount - (this.formData.selfWorkerAmount || 0)
  279. )
  280. this.formData.outWebsitAmount = this.setNumber(
  281. this.formData.normAmount - (this.formData.outWorkerAmount || 0)
  282. )
  283. })
  284. }
  285. },
  286. }, {
  287. md: 12,
  288. isShow: true,
  289. name: 'slot-component',
  290. attributes: { placeholder: '请输入' },
  291. formItemAttributes: {
  292. label: '',
  293. prop: '',
  294. 'label-width': "0px"
  295. },
  296. render: (h, { props, onInput }) => {
  297. var { value } = props
  298. return (
  299. <div style="color:red">注:分账金额需扣除手续费0.6%</div>
  300. )
  301. }
  302. }, {
  303. md: 12,
  304. isShow: true,
  305. name: 'el-input',
  306. attributes: { placeholder: '请输入', type: "number", disabled: !this.formData.normAmount, },
  307. formItemAttributes: {
  308. label: '自有库存师傅(分账金额)',
  309. prop: 'selfWorkerAmount',
  310. rules: [...required]
  311. },
  312. events: {
  313. input: (val) => {
  314. if (Number(val) > this.formData.normAmount) {
  315. this.formData.selfWorkerAmount = this.setNumber(
  316. this.formData.normAmount
  317. )
  318. }
  319. this.formData.selfWebsitAmount = this.setNumber(
  320. this.formData.normAmount - this.formData.selfWorkerAmount
  321. )
  322. }
  323. },
  324. slots: {
  325. append: (h, { props, onInput }) => {
  326. return <div>元</div>
  327. }
  328. }
  329. }, {
  330. md: 12,
  331. isShow: true,
  332. name: 'el-input',
  333. attributes: { placeholder: '请输入', type: "number", disabled: !this.formData.normAmount, },
  334. formItemAttributes: {
  335. label: '外购辅材师傅(分账金额)',
  336. prop: 'outWorkerAmount',
  337. rules: [...required]
  338. },
  339. events: {
  340. input: (val) => {
  341. if (Number(val) > this.formData.normAmount) {
  342. this.formData.outWorkerAmount = this.setNumber(
  343. this.formData.normAmount
  344. )
  345. }
  346. this.formData.outWebsitAmount = this.setNumber(
  347. this.formData.normAmount - this.formData.outWorkerAmount
  348. )
  349. }
  350. },
  351. slots: {
  352. append: (h, { props, onInput }) => {
  353. return <div>元</div>
  354. }
  355. }
  356. }, {
  357. md: 12,
  358. isShow: true,
  359. name: 'el-input',
  360. attributes: { placeholder: '请输入', disabled: true, type: "number", },
  361. formItemAttributes: {
  362. label: '自有库存商户(分账金额)',
  363. prop: 'selfWebsitAmount',
  364. rules: [...required]
  365. },
  366. slots: {
  367. append: (h, { props, onInput }) => {
  368. return <div>元</div>
  369. }
  370. }
  371. }, {
  372. md: 12,
  373. isShow: true,
  374. name: 'el-input',
  375. attributes: { placeholder: '请输入', disabled: true, type: "number", },
  376. formItemAttributes: {
  377. label: '外购辅材商户(分账金额)',
  378. prop: 'outWebsitAmount',
  379. rules: [...required]
  380. },
  381. slots: {
  382. append: (h, { props, onInput }) => {
  383. return <div>元</div>
  384. }
  385. }
  386. }, {
  387. md: 24,
  388. isShow: true,
  389. name: 'el-input',
  390. attributes: { placeholder: '请输入', type: "textarea" },
  391. formItemAttributes: {
  392. label: '备注',
  393. prop: 'remark',
  394. rules: []
  395. }
  396. }]
  397. }
  398. },
  399. methods: {
  400. // 列表请求函数
  401. getList: materialNormList,
  402. // 列表导出函数
  403. exportList: materialNormListExport,
  404. // 表格列解析渲染数据更改
  405. columnParsing(item, defaultData) {
  406. return defaultData
  407. },
  408. // 监听勾选变化
  409. selectionChange(data) {
  410. this.recordSelected = data
  411. },
  412. operation() {
  413. return this.operationBtn({
  414. edit: {
  415. click: ({ row, index, column }) => {
  416. materialNormDetail({ id: row.normId }).then(res => {
  417. Object.assign(this.formData, res.data)
  418. this.formDialogType = 1
  419. this.openForm()
  420. })
  421. }
  422. },
  423. })
  424. },
  425. addData() {
  426. this.formDialogType = 0
  427. this.openForm()
  428. },
  429. openForm() {
  430. Promise.all([
  431. getTypeList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.dict_type", "compare": "=", "value": `ASSIST_UNIT` }, { "param": "a.status", "compare": "=", "value": "ON" }] }),
  432. materialCategoryTree({ state: "ON" })
  433. ]).then(([res1, res2]) => {
  434. this.partsUnitList = res1.data.records
  435. this.materialCategoryTree = res2.data.filter(item => (item.child && item.child.length > 0))
  436. this.formDialog = true;
  437. })
  438. },
  439. formCancel() {
  440. this.$refs.formRef.$refs.inlineForm.clearValidate()
  441. this.$data.formData = this.$options.data().formData
  442. this.formDialog = false
  443. },
  444. formConfirm() {
  445. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  446. if (valid) {
  447. ([materialNormAdd, materialNormEdit][this.formDialogType])(this.formData).then(res => {
  448. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  449. this.formCancel()
  450. this.$refs.pageRef.refreshList()
  451. })
  452. }
  453. })
  454. },
  455. setRowStatus(type) {
  456. materialNormBatchUpdateStatus({
  457. ids: this.recordSelected.map(item => item.normId).join(','),
  458. stateEnum: type
  459. }).then(res => {
  460. this.$message({ type: 'success', message: `设置成功!` })
  461. this.$refs.pageRef.refreshList()
  462. })
  463. },
  464. setNumber(val) {
  465. return Number(val.toFixed(2))
  466. }
  467. }
  468. }
  469. </script>
  470. <style lang="scss" scoped></style>