index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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/auxiliaryPriceManagement";
  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. "convertBitScale": "",
  95. "cost": "",
  96. "createBy": "",
  97. "createTime": "",
  98. "goodsBarcodeId": "",
  99. "goodsCategoryId": "",
  100. "goodsCode": "",
  101. "goodsId": "",
  102. "goodsImage": "",
  103. "goodsName": "",
  104. "goodsSalesConvertQty": "",
  105. "goodsSalesUnit": "",
  106. "goodsSpecification": "",
  107. "goodsSpell": "",
  108. "goodsStockUnit": "",
  109. "goodsType": "M",
  110. "manageWorkerStock": "",
  111. "marketPrice": "",
  112. "normAmount": "",
  113. "normType": "",
  114. "outWebsitAmount": "",
  115. "outWorkerAmount": "",
  116. "parentCategoryId": "",
  117. "remark": "",
  118. "selfWebsitAmount": "",
  119. "selfWorkerAmount": "",
  120. "status": "ON",
  121. },
  122. partsUnitList: [],
  123. materialCategoryTree: []
  124. }
  125. },
  126. computed: {
  127. // 更多参数
  128. moreParameters() {
  129. return []
  130. },
  131. formItems() {
  132. return [{
  133. md: 12,
  134. isShow: true,
  135. name: 'el-input',
  136. attributes: { placeholder: '请输入', disabled: true },
  137. formItemAttributes: {
  138. label: '所属商户',
  139. prop: 'companyWechatName',
  140. rules: [...required]
  141. }
  142. }, {
  143. md: 12,
  144. isShow: true,
  145. name: 'el-radio',
  146. options: [{ label: "上架", value: "ON" }, { label: "下架", value: "OFF" }],
  147. attributes: {},
  148. formItemAttributes: {
  149. label: '状态',
  150. prop: 'status',
  151. rules: [...required]
  152. },
  153. }, {
  154. md: 12,
  155. isShow: true,
  156. name: 'el-cascader',
  157. attributes: { style: "width:100%", placeholder: '请输入', options: this.materialCategoryTree, 'show-all-levels': false, props: { value: "categoryId", label: "categoryName", children: "child", emitPath: false }, clearable: true },
  158. formItemAttributes: {
  159. label: '选择分类',
  160. prop: 'goodsCategoryId',
  161. rules: [...required]
  162. },
  163. events: {
  164. change: (val) => {
  165. this.$refs.formRef.validateField(["goodsCategoryId"], (valid, invalidFields, errLabels) => { })
  166. }
  167. }
  168. }, {
  169. md: 12,
  170. isShow: true,
  171. name: 'el-input',
  172. attributes: { placeholder: '请输入' },
  173. formItemAttributes: {
  174. label: '辅材名称',
  175. prop: 'goodsName',
  176. rules: [...required]
  177. }
  178. }, {
  179. md: 12,
  180. isShow: true,
  181. name: 'el-select-add',
  182. labelKey: 'dictValue',
  183. valueKey: 'dictValue',
  184. options: this.partsUnitList,
  185. attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
  186. formItemAttributes: {
  187. label: '单位',
  188. prop: 'goodsStockUnit',
  189. rules: [...required]
  190. },
  191. events: {
  192. change: (val) => {
  193. this.$refs.formRef.validateField(["goodsStockUnit"], (valid, invalidFields, errLabels) => { })
  194. }
  195. }
  196. }, {
  197. md: 12,
  198. isShow: true,
  199. name: 'el-input',
  200. attributes: { placeholder: '请输入' },
  201. formItemAttributes: {
  202. label: '商品代码',
  203. prop: 'goodsCode',
  204. rules: []
  205. }
  206. }, {
  207. md: 12,
  208. isShow: true,
  209. name: 'el-input',
  210. attributes: { placeholder: '请输入' },
  211. formItemAttributes: {
  212. label: '规格型号',
  213. prop: 'goodsSpecification',
  214. rules: []
  215. }
  216. }, {
  217. md: 12,
  218. isShow: true,
  219. name: 'el-input',
  220. attributes: { placeholder: '请输入', type: "number" },
  221. formItemAttributes: {
  222. label: '采购价格',
  223. prop: 'cost',
  224. rules: []
  225. }
  226. }, {
  227. md: 12,
  228. isShow: true,
  229. name: 'el-input',
  230. attributes: { placeholder: '请输入', type: "number" },
  231. formItemAttributes: {
  232. label: '销售价格',
  233. prop: 'marketPrice',
  234. rules: [...required]
  235. }
  236. }, {
  237. md: 12,
  238. isShow: true,
  239. name: 'slot-component',
  240. attributes: { placeholder: '请输入' },
  241. formItemAttributes: {
  242. label: '',
  243. prop: '',
  244. 'label-width': "0px"
  245. },
  246. render: (h, { props, onInput }) => {
  247. var { value } = props
  248. return (
  249. <div style="color:red">注:销售价格即网点销售给师傅的辅材价格</div>
  250. )
  251. }
  252. }, {
  253. md: 24,
  254. isShow: true,
  255. name: 'el-input',
  256. attributes: { placeholder: '请输入', type: "textarea" },
  257. formItemAttributes: {
  258. label: '备注',
  259. prop: 'remark',
  260. rules: []
  261. }
  262. }]
  263. }
  264. },
  265. methods: {
  266. // 列表请求函数
  267. getList: materialNormList,
  268. // 列表导出函数
  269. exportList: materialNormListExport,
  270. // 表格列解析渲染数据更改
  271. columnParsing(item, defaultData) {
  272. return defaultData
  273. },
  274. // 监听勾选变化
  275. selectionChange(data) {
  276. this.recordSelected = data
  277. },
  278. // 表格操作列
  279. operation(h, { row, index, column }) {
  280. return (
  281. <div class='operation-btns'>
  282. <el-button type="text" onClick={() => {
  283. materialNormDetail({ id: row.goodsId }).then(res => {
  284. Object.assign(this.formData, res.data)
  285. this.formDialogType = 1
  286. this.openForm()
  287. })
  288. }}>编辑</el-button>
  289. </div>
  290. )
  291. },
  292. addData() {
  293. this.formDialogType = 0
  294. this.openForm()
  295. },
  296. openForm() {
  297. Promise.all([
  298. getTypeList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.dict_type", "compare": "=", "value": `PARTS_UNIT` }, { "param": "a.status", "compare": "=", "value": "ON" }] }),
  299. materialCategoryTree({state:"ON"})
  300. ]).then(([res1, res2]) => {
  301. this.partsUnitList = res1.data.records
  302. this.materialCategoryTree = res2.data.filter(item => (item.child && item.child.length > 0))
  303. this.formDialog = true;
  304. })
  305. },
  306. formCancel() {
  307. this.$refs.formRef.$refs.inlineForm.clearValidate()
  308. this.$data.formData = this.$options.data().formData
  309. this.formDialog = false
  310. },
  311. formConfirm() {
  312. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  313. if (valid) {
  314. ([materialNormAdd, materialNormEdit][this.formDialogType])({ ...this.formData, goodsType: "M" }).then(res => {
  315. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  316. this.formCancel()
  317. this.$refs.pageRef.refreshList()
  318. })
  319. }
  320. })
  321. },
  322. setRowStatus(type) {
  323. materialNormBatchUpdateStatus({
  324. ids: this.recordSelected.map(item => item.goodsId).join(','),
  325. stateEnum: type
  326. }).then(res => {
  327. this.$message({ type: 'success', message: `设置成功!` })
  328. this.$refs.pageRef.refreshList()
  329. })
  330. }
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped></style>