form_tpl.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. import ImageUpload from '@/components/file-upload'
  2. export default {
  3. data() {
  4. return {
  5. // 事件组合
  6. optionsEvensGroup: [
  7. [
  8. [
  9. {
  10. name: '新建',
  11. isRole: true,
  12. click: this.addData
  13. }
  14. ],
  15. ],
  16. ],
  17. // 表格属性
  18. tableAttributes: {
  19. // 启用勾选列
  20. selectColumn: false
  21. },
  22. // 表格事件
  23. tableEvents: {
  24. 'selection-change': this.selectionChange
  25. },
  26. recordSelected: [],
  27. formDialog: false,
  28. formDialogType: 0, // 0:新增, 1:编辑, 2:查看, 3:审核
  29. formDialogTitles: ['新增', '编辑', '查看', '审核'],
  30. pageType: this?.$route?.name,
  31. }
  32. },
  33. computed: {
  34. moreParameters() {
  35. return [
  36. {
  37. name: '状态',
  38. key: 'flag',
  39. value: '',
  40. conditions: [
  41. {
  42. label: `全部`,
  43. value: ''
  44. },
  45. {
  46. label: `已保存`,
  47. value: "SAVE"
  48. },
  49. {
  50. label: `已审核`,
  51. value: "OK"
  52. }, {
  53. label: `失败`,
  54. value: "FAIL"
  55. },
  56. ]
  57. },
  58. ]
  59. },
  60. columns() {
  61. return [
  62. ...(() => {
  63. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  64. return [{
  65. columnAttributes: {
  66. label: '大类名称',
  67. prop: 'parentCategoryId',
  68. },
  69. render: (h, { row, column, index }) => {
  70. return (
  71. row.isEditRow ?
  72. <el-select value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  73. {[].map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
  74. </el-select> :
  75. <div>{row[column.prop]}</div>
  76. )
  77. }
  78. }]
  79. }
  80. return []
  81. })(),
  82. ...(() => {
  83. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  84. return [{
  85. columnAttributes: {
  86. label: '小类名称',
  87. prop: 'goodsCategoryId',
  88. },
  89. render: (h, { row, column, index }) => {
  90. return (
  91. row.isEditRow ?
  92. <el-select value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  93. {[].map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
  94. </el-select> :
  95. <div>{row[column.prop]}</div>
  96. )
  97. }
  98. }]
  99. }
  100. return []
  101. })(),
  102. ...(() => {
  103. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  104. return [{
  105. columnAttributes: {
  106. label: '辅材名称',
  107. prop: 'avatar',
  108. },
  109. render: (h, { row, column, index }) => {
  110. return (
  111. row.isEditRow ?
  112. <el-select value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  113. {[].map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
  114. </el-select> :
  115. <div>{row[column.prop]}</div>
  116. )
  117. }
  118. }]
  119. }
  120. return []
  121. })(),
  122. ...(() => {
  123. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  124. return [{
  125. columnAttributes: {
  126. label: '配件名称',
  127. prop: 'avatar',
  128. },
  129. render: (h, { row, column, index }) => {
  130. return (
  131. row.isEditRow ?
  132. <el-select value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  133. {[].map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
  134. </el-select> :
  135. <div>{row[column.prop]}</div>
  136. )
  137. }
  138. }]
  139. }
  140. return []
  141. })(),
  142. ...(() => {
  143. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  144. return [{
  145. columnAttributes: {
  146. label: '单位',
  147. prop: 'purchaseId',
  148. }
  149. }]
  150. }
  151. return []
  152. })(),
  153. ...(() => {
  154. if (!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.pageType)) {
  155. return [{
  156. columnAttributes: {
  157. label: '数量',
  158. prop: 'recQty',
  159. },
  160. render: (h, { row, column, index }) => {
  161. return (
  162. row.isEditRow ?
  163. <el-input type="number" value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  164. </el-input> :
  165. <div>{row[column.prop]}</div>
  166. )
  167. }
  168. }]
  169. }
  170. return []
  171. })(),
  172. ...(() => {
  173. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  174. return [{
  175. columnAttributes: {
  176. label: '退货数量',
  177. prop: 'retQty',
  178. },
  179. render: (h, { row, column, index }) => {
  180. return (
  181. row.isEditRow ?
  182. <el-input type="number" value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  183. </el-input> :
  184. <div>{row[column.prop]}</div>
  185. )
  186. }
  187. }]
  188. }
  189. return []
  190. })(),
  191. ...(() => {
  192. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  193. return [{
  194. columnAttributes: {
  195. label: '退款金额',
  196. prop: 'retValue',
  197. },
  198. render: (h, { row, column, index }) => {
  199. return (
  200. row.isEditRow ?
  201. <el-input type="number" value={row[column.prop]} onInput={(val) => { row[column.prop] = val }} placeholder="请选择">
  202. </el-input> :
  203. <div>{row[column.prop]}</div>
  204. )
  205. }
  206. }]
  207. }
  208. return []
  209. })(),
  210. ...(() => {
  211. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  212. return [{
  213. columnAttributes: {
  214. label: '商品代码',
  215. prop: '',
  216. }
  217. }]
  218. }
  219. return []
  220. })(),
  221. ...(() => {
  222. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  223. return [{
  224. columnAttributes: {
  225. label: '规格型号',
  226. prop: 'goodsSpecification',
  227. }
  228. }]
  229. }
  230. return []
  231. })(),
  232. ...(() => {
  233. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  234. return [{
  235. columnAttributes: {
  236. label: '配件编码',
  237. prop: '',
  238. }
  239. }]
  240. }
  241. return []
  242. })(),
  243. ...(() => {
  244. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  245. return [{
  246. columnAttributes: {
  247. label: '适用品牌',
  248. prop: '',
  249. }
  250. }]
  251. }
  252. return []
  253. })(),
  254. ...(() => {
  255. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  256. return [{
  257. columnAttributes: {
  258. label: '适用产品大类',
  259. prop: '',
  260. }
  261. }]
  262. }
  263. return []
  264. })(),
  265. ...(() => {
  266. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  267. return [{
  268. columnAttributes: {
  269. label: '采购数量',
  270. prop: '',
  271. }
  272. }]
  273. }
  274. return []
  275. })(),
  276. ...(() => {
  277. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  278. return [{
  279. columnAttributes: {
  280. label: '采购价格',
  281. prop: '',
  282. }
  283. }]
  284. }
  285. return []
  286. })(),
  287. ...(() => {
  288. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  289. return [{
  290. columnAttributes: {
  291. label: '采购金额',
  292. prop: '',
  293. }
  294. }]
  295. }
  296. return []
  297. })(),
  298. ...(() => {
  299. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  300. return [{
  301. columnAttributes: {
  302. label: '库存数量',
  303. prop: '',
  304. }
  305. }]
  306. }
  307. return []
  308. })(),
  309. ...(() => {
  310. if (!!~[0, 1].indexOf(this.formDialogType)) {
  311. return [{
  312. columnAttributes: {
  313. label: '操作',
  314. prop: '',
  315. },
  316. render: (h, { row, column, index }) => {
  317. return (
  318. <div class='operation-btns'>
  319. <el-button type="text" onClick={() => {
  320. this.formData.items.map((item, index_) => {
  321. if (index_ == index) {
  322. item.isEditRow = true
  323. } else {
  324. item.isEditRow = false
  325. }
  326. })
  327. }}>编辑</el-button>
  328. <el-button type="text" onClick={() => {
  329. this.formData.items.splice(index, 1)
  330. }}>删除</el-button>
  331. </div>
  332. )
  333. }
  334. }]
  335. }
  336. return []
  337. })(),
  338. ]
  339. },
  340. formItems1() {
  341. return [
  342. {
  343. md: 24,
  344. isShow: true,
  345. name: 'slot-component',
  346. formItemAttributes: {
  347. label: '',
  348. prop: '',
  349. 'label-width': '0px'
  350. },
  351. render: (h, { props, onInput }) => {
  352. var { value } = props
  353. return (
  354. <div>
  355. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }}>
  356. <el-descriptions-item label="单据状态">
  357. {({ SAVE: "保存", OK: "通过", FAIL: "失败" })[this.formData.flag]}
  358. </el-descriptions-item>
  359. <el-descriptions-item label="单据编号">
  360. {(!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.pageType) ? this.formData.purchaseId : this.formData.purchaseRetId) || ''}
  361. </el-descriptions-item>
  362. <el-descriptions-item label="所属商户" contentStyle={{ width: '42%' }}>
  363. {this.formData.companyWechatName}
  364. </el-descriptions-item>
  365. </el-descriptions>
  366. <el-descriptions border title="" column={2} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '42%' }} style="margin-top:-1px">
  367. <el-descriptions-item label="网点名称">
  368. {this.formData.websitName}
  369. </el-descriptions-item>
  370. <el-descriptions-item label="供应商名称">
  371. {this.formData.venderName}
  372. </el-descriptions-item>
  373. </el-descriptions>
  374. {
  375. !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType) ?
  376. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  377. <el-descriptions-item label="采购入库单号" contentStyle={{ width: '42%' }}>
  378. {this.formData.purchaseId}
  379. </el-descriptions-item>
  380. <el-descriptions-item label="退货数量">
  381. {this.formData.purchaseId}
  382. </el-descriptions-item>
  383. <el-descriptions-item label="退款金额">
  384. {this.formData.purchaseId}
  385. </el-descriptions-item>
  386. </el-descriptions> : null
  387. }
  388. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  389. <el-descriptions-item label="制单人">
  390. {this.formData.createBy}
  391. </el-descriptions-item>
  392. <el-descriptions-item label="制单时间">
  393. {this.formData.createTime}
  394. </el-descriptions-item>
  395. <el-descriptions-item label="审核人">
  396. {this.formData.confirmBy}
  397. </el-descriptions-item>
  398. <el-descriptions-item label="审核时间">
  399. {this.formData.confirmTime}
  400. </el-descriptions-item>
  401. </el-descriptions>
  402. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  403. <el-descriptions-item label="附件">
  404. <ImageUpload fileList={this.formData.imageUrl} uid="imgSrc666_materials_drawing_images" limit={1} isEdit={this.formDialogType < 2} />
  405. </el-descriptions-item>
  406. <el-descriptions-item label="备注" contentStyle={{ width: '67%' }}>
  407. <el-input
  408. type="textarea"
  409. placeholder="请输入内容"
  410. value={this.formData.remark}
  411. onInput={(val) => { this.formData.remark = val }}
  412. maxlength="200"
  413. show-word-limit
  414. autosize={{ minRows: 6, maxRows: 8 }}
  415. >
  416. </el-input>
  417. </el-descriptions-item>
  418. </el-descriptions>
  419. </div>
  420. )
  421. }
  422. },]
  423. },
  424. formItems2() {
  425. return [
  426. {
  427. md: 24,
  428. isShow: true,
  429. name: 'slot-component',
  430. formItemAttributes: {
  431. label: '',
  432. prop: '',
  433. 'label-width': '0px'
  434. },
  435. render: (h, { props, onInput }) => {
  436. var { value } = props
  437. return (
  438. <div>
  439. {!!~[0, 1].indexOf(this.formDialogType) ? <div style="margin-bottom:8px">
  440. <el-button onClick={() => {
  441. this.formData.items.push({
  442. "brand": "",
  443. "companyWechatId": "",
  444. "cost": "",
  445. "costValue": "",
  446. "goodsCategoryId": "",
  447. "goodsCategoryName": "",
  448. "goodsId": "",
  449. "goodsName": "",
  450. "goodsSpecification": "",
  451. "goodsStockUnit": "",
  452. "goodsType": "",
  453. "note": "",
  454. "parentCategoryId": "",
  455. "parentCategoryName": "",
  456. "productCategory": "",
  457. "purchaseId": "",
  458. "recQty": "",
  459. "retQty": "",
  460. "stockQty": "",
  461. "websitId": "",
  462. "websitName": ""
  463. })
  464. // if (this.pageType == "auxiliaryMaterialsStorage") {
  465. // } else if (this.pageType == "returnAuxiliaryMaterials") {
  466. // } else if (this.pageType == "partsStorage") {
  467. // } else if (this.pageType == "partsReturn") {
  468. // }
  469. }}>添加</el-button>
  470. </div> : null}
  471. <zj-table
  472. columns={this.columns}
  473. tableData={this.formData.items}
  474. tableAttributes={{
  475. size: 'mini',
  476. border: true,
  477. }} />
  478. </div>
  479. )
  480. }
  481. },]
  482. }
  483. },
  484. methods: {
  485. // 表格列解析渲染数据更改
  486. columnParsing(item, defaultData) {
  487. return defaultData
  488. },
  489. // 监听勾选变化
  490. selectionChange(data) {
  491. this.recordSelected = data
  492. },
  493. // 打开
  494. openForm() {
  495. {/* Promise.all([
  496. ]).then(([res1]) => {
  497. }) */}
  498. this.formDialog = true
  499. },
  500. // 添加
  501. addData() {
  502. this.formDialogType = 0
  503. this.openForm()
  504. },
  505. // 关闭弹窗
  506. formCancel() {
  507. this.$refs.formRef.$refs.inlineForm.clearValidate()
  508. this.$data.formData = this.$options.data().formData
  509. this.formDialog = false
  510. },
  511. },
  512. }