index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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 } from "@/api/auxiliaryChargeManagement";
  24. import { materialCategoryTree } from "@/api/auxiliaryMaterialClass";
  25. import { getTypeList } from "@/api/auxiliaryFittings/attachmentProfile";
  26. export default {
  27. components: { TemplatePage },
  28. mixins: [import_mixin],
  29. data() {
  30. return {
  31. // 事件组合
  32. optionsEvensGroup: [
  33. [
  34. [
  35. {
  36. name: '新建',
  37. isRole: true,
  38. click: this.addData
  39. }
  40. ],
  41. ],
  42. [
  43. [
  44. {
  45. name: '批量上架',
  46. isRole: true,
  47. click: () => {
  48. if (this.recordSelected.length) {
  49. this.setRowStatus("ON")
  50. } else {
  51. this.$message({
  52. type: 'warning',
  53. message: `请先勾选需要设置的数据!`,
  54. });
  55. }
  56. }
  57. }
  58. ],
  59. [
  60. {
  61. name: '批量下架',
  62. isRole: true,
  63. click: () => {
  64. if (this.recordSelected.length) {
  65. this.setRowStatus("OFF")
  66. } else {
  67. this.$message({
  68. type: 'warning',
  69. message: `请先勾选需要设置的数据!`,
  70. });
  71. }
  72. }
  73. }
  74. ],
  75. ],
  76. ],
  77. // 表格属性
  78. tableAttributes: {
  79. // 启用勾选列
  80. selectColumn: true
  81. },
  82. // 表格事件
  83. tableEvents: {
  84. 'selection-change': this.selectionChange
  85. },
  86. // 勾选选中行
  87. recordSelected: [],
  88. /** 表单变量 */
  89. formDialogType: 0,
  90. formDialogTitles: ["新增", "编辑"],
  91. formDialog: false,
  92. formData: {
  93. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  94. "categoryId": "",
  95. "companyWechatId": "",
  96. "createBy": "",
  97. "createTime": "",
  98. "normAmount": 0,
  99. "normCode": "",
  100. "normId": "",
  101. "normName": "",
  102. "normType": "",
  103. "outWebsitAmount": 0,
  104. "outWorkerAmount": 0,
  105. "parentCategoryId": "",
  106. "remark": "",
  107. "selfWebsitAmount": 0,
  108. "selfWorkerAmount": 0,
  109. "specification": "",
  110. "status": "ON",
  111. "unit": "",
  112. },
  113. partsUnitList: [],
  114. materialCategoryTree: []
  115. }
  116. },
  117. computed: {
  118. // 更多参数
  119. moreParameters() {
  120. return []
  121. },
  122. formItems() {
  123. return [{
  124. md: 12,
  125. isShow: true,
  126. name: 'el-input',
  127. attributes: { placeholder: '请输入', disabled: true },
  128. formItemAttributes: {
  129. label: '所属商户',
  130. prop: 'companyWechatName',
  131. rules: [...required]
  132. }
  133. }, {
  134. md: 12,
  135. isShow: true,
  136. name: 'el-radio',
  137. options: [{ label: "上架", value: "ON" }, { label: "下架", value: "OFF" }],
  138. attributes: {},
  139. formItemAttributes: {
  140. label: '状态',
  141. prop: 'status',
  142. rules: [...required]
  143. },
  144. }, {
  145. md: 12,
  146. isShow: true,
  147. name: 'el-cascader',
  148. attributes: { style: "width:100%", placeholder: '请输入', options: this.materialCategoryTree, 'show-all-levels': false, props: { value: "categoryId", label: "categoryName", children: "child", emitPath: false }, clearable: true },
  149. formItemAttributes: {
  150. label: '选择分类',
  151. prop: 'categoryId',
  152. rules: [...required]
  153. }
  154. }, {
  155. md: 12,
  156. isShow: true,
  157. name: 'el-input',
  158. attributes: { placeholder: '请输入' },
  159. formItemAttributes: {
  160. label: '辅材名称',
  161. prop: 'normName',
  162. rules: [...required]
  163. }
  164. }, {
  165. md: 12,
  166. isShow: true,
  167. name: 'el-select-add',
  168. labelKey: 'dictValue',
  169. valueKey: 'dictValue',
  170. options: this.partsUnitList,
  171. attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
  172. formItemAttributes: {
  173. label: '单位',
  174. prop: 'unit',
  175. rules: [...required]
  176. }
  177. }, {
  178. md: 12,
  179. isShow: true,
  180. name: 'el-input',
  181. attributes: { placeholder: '请输入' },
  182. formItemAttributes: {
  183. label: '商品代码',
  184. prop: 'normCode',
  185. rules: []
  186. }
  187. }, {
  188. md: 12,
  189. isShow: true,
  190. name: 'el-input',
  191. attributes: { placeholder: '请输入' },
  192. formItemAttributes: {
  193. label: '规格型号',
  194. prop: 'specification',
  195. rules: []
  196. }
  197. }, {
  198. md: 12,
  199. isShow: true,
  200. name: 'el-radio',
  201. options: [{ label: "物料收费", value: "M" }, { label: "服务收费", value: "S" }],
  202. attributes: {},
  203. formItemAttributes: {
  204. label: '收费类型',
  205. prop: 'normType',
  206. rules: [...required]
  207. },
  208. }, {
  209. md: 12,
  210. isShow: true,
  211. name: 'el-input',
  212. attributes: { placeholder: '请输入', type: "number" },
  213. formItemAttributes: {
  214. label: '收费标准',
  215. prop: 'normAmount',
  216. rules: [...required]
  217. },
  218. events: {
  219. input: (val) => {
  220. this.formData.selfWorkerAmount = ""
  221. this.formData.outWorkerAmount = ""
  222. this.$nextTick(() => {
  223. this.formData.selfWebsitAmount = this.formData.normAmount - (this.formData.selfWorkerAmount || 0)
  224. this.formData.outWebsitAmount = this.formData.normAmount - (this.formData.outWorkerAmount || 0)
  225. })
  226. }
  227. },
  228. }, {
  229. md: 12,
  230. isShow: true,
  231. name: 'slot-component',
  232. attributes: { placeholder: '请输入' },
  233. formItemAttributes: {
  234. label: '',
  235. prop: '',
  236. 'label-width': "0px"
  237. },
  238. render: (h, { props, onInput }) => {
  239. var { value } = props
  240. return (
  241. <div style="color:red">注:分账金额需扣除手续费0.6%</div>
  242. )
  243. }
  244. }, {
  245. md: 12,
  246. isShow: true,
  247. name: 'el-input',
  248. attributes: { placeholder: '请输入', type: "number", disabled: !this.formData.normAmount, },
  249. formItemAttributes: {
  250. label: '自有库存师傅(分账金额)',
  251. prop: 'selfWorkerAmount',
  252. rules: [...required]
  253. },
  254. events: {
  255. input: (val) => {
  256. if (Number(val) > this.formData.normAmount) {
  257. this.formData.selfWorkerAmount = this.formData.normAmount
  258. }
  259. this.formData.selfWebsitAmount = this.formData.normAmount - this.formData.selfWorkerAmount
  260. }
  261. },
  262. slots: {
  263. append: (h, { props, onInput }) => {
  264. return <div>元</div>
  265. }
  266. }
  267. }, {
  268. md: 12,
  269. isShow: true,
  270. name: 'el-input',
  271. attributes: { placeholder: '请输入', type: "number", disabled: !this.formData.normAmount, },
  272. formItemAttributes: {
  273. label: '外购辅材师傅(分账金额)',
  274. prop: 'outWorkerAmount',
  275. rules: [...required]
  276. },
  277. events: {
  278. input: (val) => {
  279. if (Number(val) > this.formData.normAmount) {
  280. this.formData.outWorkerAmount = this.formData.normAmount
  281. }
  282. this.formData.outWebsitAmount = this.formData.normAmount - this.formData.outWorkerAmount
  283. }
  284. },
  285. slots: {
  286. append: (h, { props, onInput }) => {
  287. return <div>元</div>
  288. }
  289. }
  290. }, {
  291. md: 12,
  292. isShow: true,
  293. name: 'el-input',
  294. attributes: { placeholder: '请输入', disabled: true, type: "number", },
  295. formItemAttributes: {
  296. label: '自有库存网点(分账金额)',
  297. prop: 'selfWebsitAmount',
  298. rules: [...required]
  299. },
  300. slots: {
  301. append: (h, { props, onInput }) => {
  302. return <div>元</div>
  303. }
  304. }
  305. }, {
  306. md: 12,
  307. isShow: true,
  308. name: 'el-input',
  309. attributes: { placeholder: '请输入', disabled: true, type: "number", },
  310. formItemAttributes: {
  311. label: '外购辅材网点(分账金额)',
  312. prop: 'outWebsitAmount',
  313. rules: [...required]
  314. },
  315. slots: {
  316. append: (h, { props, onInput }) => {
  317. return <div>元</div>
  318. }
  319. }
  320. }, {
  321. md: 24,
  322. isShow: true,
  323. name: 'el-input',
  324. attributes: { placeholder: '请输入', type: "textarea" },
  325. formItemAttributes: {
  326. label: '备注',
  327. prop: 'remark',
  328. rules: []
  329. }
  330. }]
  331. }
  332. },
  333. methods: {
  334. // 列表请求函数
  335. getList: materialNormList,
  336. // 列表导出函数
  337. exportList: materialNormListExport,
  338. // 表格列解析渲染数据更改
  339. columnParsing(item, defaultData) {
  340. return defaultData
  341. },
  342. // 监听勾选变化
  343. selectionChange(data) {
  344. this.recordSelected = data
  345. },
  346. // 表格操作列
  347. operation(h, { row, index, column }) {
  348. return (
  349. <div class='operation-btns'>
  350. <el-button type="text" onClick={() => {
  351. materialNormDetail({ id: row.normId }).then(res => {
  352. Object.assign(this.formData, res.data)
  353. this.formDialogType = 1
  354. this.openForm()
  355. })
  356. }}>编辑</el-button>
  357. </div>
  358. )
  359. },
  360. addData() {
  361. this.formDialogType = 0
  362. this.openForm()
  363. },
  364. openForm() {
  365. Promise.all([
  366. getTypeList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.dict_type", "compare": "=", "value": `PARTS_UNIT` }, { "param": "a.status", "compare": "=", "value": "ON" }] }),
  367. materialCategoryTree()
  368. ]).then(([res1, res2]) => {
  369. this.partsUnitList = res1.data.records
  370. this.materialCategoryTree = res2.data.filter(item => (item.child && item.child.length > 0))
  371. this.formDialog = true;
  372. })
  373. },
  374. formCancel() {
  375. this.$refs.formRef.$refs.inlineForm.clearValidate()
  376. this.$data.formData = this.$options.data().formData
  377. this.formDialog = false
  378. },
  379. formConfirm() {
  380. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  381. if (valid) {
  382. ([materialNormAdd, materialNormEdit][this.formDialogType])(this.formData).then(res => {
  383. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  384. this.formCancel()
  385. this.$refs.pageRef.refreshList()
  386. })
  387. }
  388. })
  389. },
  390. setRowStatus(type) {
  391. materialNormBatchUpdateStatus({
  392. ids: this.recordSelected.map(item => item.normId).join(','),
  393. stateEnum: type
  394. }).then(res => {
  395. this.$message({ type: 'success', message: `设置成功!` })
  396. this.$refs.pageRef.refreshList()
  397. })
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped></style>