index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. <script>
  2. import useColumns from "./columns";
  3. import {EXIST} from "@/api/business/purchase/catalogue";
  4. import {SAVE} from "@/api/business/purchase/apply";
  5. import {tax, unit, currency} from "@/components/popover-select-v2/fetch";
  6. // 用于回显参照框数据
  7. import {getRefer} from '@/api/purchase/basic.js'
  8. const fetchExist = async (prop) => {
  9. try {
  10. // try
  11. const {code, data} = await EXIST(prop);
  12. if (code === 200) return data;
  13. } catch (err) {
  14. // catch
  15. console.error(err);
  16. } finally {
  17. // finally
  18. }
  19. };
  20. export default {
  21. name: "AddDrawer",
  22. props: {
  23. dict: {
  24. type: Object,
  25. },
  26. },
  27. components: {
  28. ElSuperForm: () => import("@/components/super-form/index.vue"),
  29. ElSuperTable: () => import("@/components/super-table/index.vue"),
  30. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  31. ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
  32. },
  33. data() {
  34. const {
  35. TabColumns,
  36. TableColumns,
  37. TabColumns: [
  38. {
  39. item: {key: tabName},
  40. },
  41. ],
  42. } = useColumns();
  43. const rules = this.$init.rules([...TabColumns, ...TableColumns]);
  44. const params = this.$init.params([...TabColumns, ...TableColumns]);
  45. return {
  46. title: "新 增",
  47. width: "100%",
  48. visible: false,
  49. loading: false,
  50. rules: rules,
  51. params: params,
  52. tabName: tabName,
  53. TabColumns: TabColumns,
  54. TableColumns: TableColumns,
  55. delDemandItemList: [],
  56. };
  57. },
  58. computed: {},
  59. watch: {},
  60. methods: {
  61. //
  62. async changeMaterialName(prop) {
  63. const {selectData} = prop;
  64. const {
  65. puOrg,
  66. customer,
  67. supplier,
  68. currency,
  69. currencyCode,
  70. currencyName,
  71. } = this.params;
  72. const {nickName: createByName} = this.$store.state.user;
  73. if (selectData.length) {
  74. this.params[this.tabName].splice(-1);
  75. }
  76. for (const item of selectData) {
  77. this.loading = true;
  78. const {tax: taxName, unitName, code: materialCode} = item;
  79. // task 1
  80. const {ntaxrate} = await tax(taxName);
  81. // task 2
  82. const {
  83. id: puUnit,
  84. code: puUnitCode,
  85. name: puUnitName,
  86. } = await unit(unitName);
  87. // task 3
  88. const {
  89. recentlyPrice = "0",
  90. isApprovalFirst = "N",
  91. purchasequantity,
  92. recentlyPriceDate
  93. } = await fetchExist({
  94. puOrg,
  95. customer,
  96. supplier,
  97. materialCode,
  98. customerName: "",
  99. priceType: prop.row.priceType
  100. });
  101. this.loading = false;
  102. await this.onRowAdd(this.tabName, {
  103. ...item,
  104. currency: currency,
  105. currencyCode: currencyCode,
  106. currencyName: currencyName,
  107. unit: puUnit,
  108. unitCode: puUnitCode,
  109. unitName: puUnitName,
  110. puUnit: puUnit,
  111. puUnitCode: puUnitCode,
  112. puUnitName: puUnitName,
  113. recentlyPrice,
  114. isApprovalFirst,
  115. recentlyPriceDate: recentlyPriceDate,
  116. yPurchaseQuantity: purchasequantity,
  117. tax: Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
  118. createByName: createByName,
  119. updateByName: createByName,
  120. id: null,
  121. });
  122. }
  123. },
  124. //
  125. async changeCustomerName(prop) {
  126. console.log("prop", prop)
  127. const {
  128. puOrg,
  129. supplier,
  130. currency,
  131. currencyCode,
  132. currencyName,
  133. } = this.params;
  134. const {
  135. recentlyPrice,
  136. isApprovalFirst,
  137. purchasequantity,
  138. recentlyPriceDate
  139. } = await fetchExist({
  140. puOrg,
  141. supplier,
  142. materialCode: prop.row.materialCode,
  143. customer: prop.row.customerName ? prop.row.customer : '',
  144. customerName: prop.row.customerName,
  145. priceType: prop.row.priceType
  146. });
  147. prop.row.yPurchaseQuantity = purchasequantity
  148. prop.row.recentlyPrice = recentlyPrice
  149. prop.row.isApprovalFirst = isApprovalFirst
  150. prop.row.recentlyPriceDate = recentlyPriceDate
  151. },
  152. //
  153. async onOpen() {
  154. this.visible = true;
  155. const {
  156. deptId: puDept,
  157. deptName: puDeptName,
  158. name: buyer,
  159. nickName: buyerName,
  160. } = this.$store.state.user;
  161. const {id, code, name} = await currency("人民币");
  162. this.params.currency = id;
  163. this.params.currencyCode = code;
  164. this.params.currencyName = name;
  165. this.params.buyer = buyer;
  166. this.params.buyerName = buyerName;
  167. this.params.puDept = puDept;
  168. this.params.puDeptName = puDeptName;
  169. },
  170. //
  171. async onHide() {
  172. const {TabColumns, TableColumns} = useColumns();
  173. this.visible = false;
  174. this.params = this.$init.params([...TabColumns, ...TableColumns]);
  175. this.$emit("success");
  176. this.delDemandItemList = []
  177. },
  178. //
  179. async onRowAdd(prop, pushParams = {}) {
  180. this.$refs.superForm.validate(async (valid) => {
  181. if (valid) {
  182. const {TabColumns} = this;
  183. const {TableColumns} = TabColumns.find(
  184. ({item: {key}}) => key === prop
  185. );
  186. this.params[prop].push({
  187. delFlag: "0",
  188. ...this.$init.params(TableColumns),
  189. ...pushParams,
  190. });
  191. }
  192. });
  193. },
  194. //
  195. async onRowRemove(prop, scope) {
  196. // const {$index} = scope;
  197. // this.params[prop].splice($index, 1);
  198. scope.row.delFlag = '2'
  199. let delList = []
  200. delList = this.params[prop].filter(item => {
  201. return item.delFlag == '2'
  202. })
  203. this.params[prop] = this.params[prop].filter(item => {
  204. return item.delFlag == '0'
  205. })
  206. this.delDemandItemList.push(...delList)
  207. },
  208. //
  209. async useSubmit(prop) {
  210. this.$refs[prop].validate(async (valid) => {
  211. if (valid) {
  212. try {
  213. this.loading = true;
  214. let list = []
  215. list.push(...this.params.priceApplyItems, ...this.delDemandItemList)
  216. this.params.priceApplyItems = this.params.priceApplyItems.filter(
  217. (item) => item.materialName
  218. );
  219. // 深拷贝一下参数对象
  220. let param = JSON.parse(JSON.stringify(this.params))
  221. // console.log('深拷贝对象',param);
  222. param.priceApplyItems = list
  223. param.priceApplyItems.forEach((item, index) => {
  224. item.$index = index
  225. });
  226. let tishi = param.priceApplyItems.filter(item => {return (item.priceDiffer && item.delFlag == '0' && item.priceDiffer !== 0)})
  227. // console.log('筛选', tishi)
  228. let tishiMsg = tishi.map(item => {
  229. return `第${item.$index+1}行为价格调整`
  230. })
  231. // console.log(tishiMsg)
  232. if(tishiMsg.length !== 0) {
  233. this.$modal.confirm(tishiMsg+ '请核对后再次提交').then(async () =>{
  234. const {msg, code} = await SAVE(param);
  235. if (code === 200) {
  236. this.onHide();
  237. this.$emit("success");
  238. this.$notify.success(msg);
  239. this.delDemandItemList = []
  240. }
  241. }).catch(() => {});
  242. } else {
  243. const {msg, code} = await SAVE(param);
  244. if (code === 200) {
  245. this.onHide();
  246. this.$emit("success");
  247. this.$notify.success(msg);
  248. this.delDemandItemList = []
  249. }
  250. }
  251. } catch (err) {
  252. // catch
  253. console.error(err);
  254. } finally {
  255. // finally
  256. this.loading = false;
  257. }
  258. } else {
  259. return false;
  260. }
  261. });
  262. },
  263. // 粘贴
  264. async pasteMe(e, scope, index, prop) {
  265. this.$modal.loading("正在处理数据...");
  266. e.preventDefault() //阻止默认粘贴事件
  267. let source = e.clipboardData.getData("Text");
  268. console.log('scope', scope.column.property)
  269. console.log('index', index)
  270. // 首先对源头进行解析
  271. let rows = source.split("\r\n"); // 拆成一个数组
  272. // 数组去除空字符串
  273. rows = rows.filter(item => {
  274. return item && item.trim()
  275. })
  276. if (rows.length < 100) {
  277. if(scope.column.property == 'materialCode') {
  278. let rowList = []
  279. let newLine = []
  280. await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
  281. if (res.code === 200) {
  282. rowList = res.rows
  283. }
  284. }).catch(err => {
  285. this.$modal.closeLoading();
  286. })
  287. const {
  288. puOrg,
  289. customer,
  290. customerName,
  291. supplier,
  292. currency,
  293. currencyCode,
  294. currencyName,
  295. } = this.params;
  296. const {TabColumns} = this;
  297. const {TableColumns} = TabColumns.find(
  298. ({item: {key}}) => key === prop
  299. );
  300. // console.log('kk', TableColumns)
  301. // console.log('this.$init.params(TableColumns)', this.$init.params(TableColumns))
  302. for (let i = 0; i<rowList.length; i++) {
  303. let line = {...this.$init.params(TableColumns)}
  304. console.log('line',line)
  305. const {nickName: createByName} = this.$store.state.user;
  306. const {ntaxrate} = await tax(rowList[i].materialRateName);
  307. // task 2
  308. const {
  309. id: puUnit,
  310. code: puUnitCode,
  311. name: puUnitName,
  312. } = await unit(rowList[i].unitIdName);
  313. // task 3
  314. const {
  315. recentlyPrice = "0",
  316. isApprovalFirst = "N",
  317. purchasequantity,
  318. recentlyPriceDate
  319. } = await fetchExist({puOrg, customer, supplier, materialCode: rowList[i].code, customerName: "", priceType: line.priceType});
  320. line.delFlag = '0'
  321. line.materialCode = rowList[i].code
  322. line.material = rowList[i].id
  323. line.materialName = rowList[i].name
  324. line.specification = rowList[i].specification
  325. line.model = rowList[i].model
  326. line.manufacturerName = rowList[i].manufacturerIdName
  327. line.unit = puUnit,
  328. line.unitCode = puUnitCode,
  329. line.unitName = puUnitName,
  330. line.puUnit = puUnit,
  331. line.puUnitCode = puUnitCode,
  332. line.puUnitName = puUnitName,
  333. line.recentlyPrice = recentlyPrice
  334. line.isApprovalFirst = isApprovalFirst
  335. line.recentlyPriceDate = recentlyPriceDate,
  336. line.yPurchaseQuantity = purchasequantity,
  337. line.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
  338. line.createByName = createByName,
  339. line.updateByName = createByName,
  340. line.currency = currency
  341. line.currencyCode = currencyCode
  342. line.currencyName = currencyName
  343. newLine.push(line)
  344. console.log('临时数组', newLine)
  345. }
  346. // 删除指定下标
  347. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  348. this.$modal.closeLoading();
  349. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  350. } else if(scope.column.property == 'taxPrice') {
  351. console.log('复制内容:', rows)
  352. let newLine = []
  353. const {TabColumns} = this;
  354. const {TableColumns} = TabColumns.find(
  355. ({item: {key}}) => key === prop
  356. );
  357. if(this.params[prop].length <= 1) {
  358. for (let i = 0; i<rows.length; i++) {
  359. let line = {...this.$init.params(TableColumns)}
  360. line.taxPrice = rows[i]
  361. newLine.push(line)
  362. }
  363. // 删除指定下标
  364. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  365. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  366. // this.$refs.table.doLayout()
  367. this.$modal.closeLoading();
  368. } else {
  369. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  370. this.params[prop][i].taxPrice = rows[j]
  371. }
  372. // this.$refs.table.doLayout()
  373. console.log(this.params[prop])
  374. this.$modal.closeLoading();
  375. }
  376. } else if(scope.column.property == 'supplierName') {
  377. console.log('复制内容:', rows)
  378. let newLine = []
  379. const {TabColumns} = this;
  380. const {TableColumns} = TabColumns.find(
  381. ({item: {key}}) => key === prop
  382. );
  383. if(this.params[prop].length <= 1) {
  384. for (let i = 0; i<rows.length; i++) {
  385. let line = {...this.$init.params(TableColumns)}
  386. line.supplierName = rows[i]
  387. newLine.push(line)
  388. }
  389. // 删除指定下标
  390. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  391. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  392. // this.$refs.table.doLayout()
  393. this.$modal.closeLoading();
  394. } else {
  395. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  396. this.params[prop][i].supplierName = rows[j]
  397. }
  398. // this.$refs.table.doLayout()
  399. console.log(this.params[prop])
  400. this.$modal.closeLoading();
  401. }
  402. } else if(scope.column.property == 'bidPrice') {
  403. console.log('复制内容:', rows)
  404. let newLine = []
  405. const {TabColumns} = this;
  406. const {TableColumns} = TabColumns.find(
  407. ({item: {key}}) => key === prop
  408. );
  409. if(this.params[prop].length <= 1) {
  410. for (let i = 0; i<rows.length; i++) {
  411. let line = {...this.$init.params(TableColumns)}
  412. line.bidPrice = rows[i]
  413. newLine.push(line)
  414. }
  415. // 删除指定下标
  416. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  417. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  418. // this.$refs.table.doLayout()
  419. this.$modal.closeLoading();
  420. } else {
  421. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  422. this.params[prop][i].bidPrice = rows[j]
  423. }
  424. // this.$refs.table.doLayout()
  425. console.log(this.params[prop])
  426. this.$modal.closeLoading();
  427. }
  428. } else if(scope.column.property == 'unitPrice') {
  429. console.log('复制内容:', rows)
  430. let newLine = []
  431. const {TabColumns} = this;
  432. const {TableColumns} = TabColumns.find(
  433. ({item: {key}}) => key === prop
  434. );
  435. if(this.params[prop].length <= 1) {
  436. for (let i = 0; i<rows.length; i++) {
  437. let line = {...this.$init.params(TableColumns)}
  438. line.unitPrice = rows[i]
  439. newLine.push(line)
  440. }
  441. // 删除指定下标
  442. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  443. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  444. // this.$refs.table.doLayout()
  445. this.$modal.closeLoading();
  446. } else {
  447. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  448. this.params[prop][i].unitPrice = rows[j]
  449. }
  450. // this.$refs.table.doLayout()
  451. console.log(this.params[prop])
  452. this.$modal.closeLoading();
  453. }
  454. } else if(scope.column.property == 'supplierName1') {
  455. console.log('复制内容:', rows)
  456. let newLine = []
  457. const {TabColumns} = this;
  458. const {TableColumns} = TabColumns.find(
  459. ({item: {key}}) => key === prop
  460. );
  461. if(this.params[prop].length <= 1) {
  462. for (let i = 0; i<rows.length; i++) {
  463. let line = {...this.$init.params(TableColumns)}
  464. line.supplierName1 = rows[i]
  465. newLine.push(line)
  466. }
  467. // 删除指定下标
  468. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  469. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  470. // this.$refs.table.doLayout()
  471. this.$modal.closeLoading();
  472. } else {
  473. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  474. this.params[prop][i].supplierName1 = rows[j]
  475. }
  476. // this.$refs.table.doLayout()
  477. console.log(this.params[prop])
  478. this.$modal.closeLoading();
  479. }
  480. } else if(scope.column.property == 'bidPrice1') {
  481. console.log('复制内容:', rows)
  482. let newLine = []
  483. const {TabColumns} = this;
  484. const {TableColumns} = TabColumns.find(
  485. ({item: {key}}) => key === prop
  486. );
  487. if(this.params[prop].length <= 1) {
  488. for (let i = 0; i<rows.length; i++) {
  489. let line = {...this.$init.params(TableColumns)}
  490. line.bidPrice1 = rows[i]
  491. newLine.push(line)
  492. }
  493. // 删除指定下标
  494. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  495. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  496. // this.$refs.table.doLayout()
  497. this.$modal.closeLoading();
  498. } else {
  499. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  500. this.params[prop][i].bidPrice1 = rows[j]
  501. }
  502. // this.$refs.table.doLayout()
  503. console.log(this.params[prop])
  504. this.$modal.closeLoading();
  505. }
  506. } else if(scope.column.property == 'unitPrice1') {
  507. console.log('复制内容:', rows)
  508. let newLine = []
  509. const {TabColumns} = this;
  510. const {TableColumns} = TabColumns.find(
  511. ({item: {key}}) => key === prop
  512. );
  513. if(this.params[prop].length <= 1) {
  514. for (let i = 0; i<rows.length; i++) {
  515. let line = {...this.$init.params(TableColumns)}
  516. line.unitPrice1 = rows[i]
  517. newLine.push(line)
  518. }
  519. // 删除指定下标
  520. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  521. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  522. // this.$refs.table.doLayout()
  523. this.$modal.closeLoading();
  524. } else {
  525. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  526. this.params[prop][i].unitPrice1 = rows[j]
  527. }
  528. // this.$refs.table.doLayout()
  529. console.log(this.params[prop])
  530. this.$modal.closeLoading();
  531. }
  532. } else if(scope.column.property == 'supplierName2') {
  533. console.log('复制内容:', rows)
  534. let newLine = []
  535. const {TabColumns} = this;
  536. const {TableColumns} = TabColumns.find(
  537. ({item: {key}}) => key === prop
  538. );
  539. if(this.params[prop].length <= 1) {
  540. for (let i = 0; i<rows.length; i++) {
  541. let line = {...this.$init.params(TableColumns)}
  542. line.supplierName2 = rows[i]
  543. newLine.push(line)
  544. }
  545. // 删除指定下标
  546. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  547. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  548. // this.$refs.table.doLayout()
  549. this.$modal.closeLoading();
  550. } else {
  551. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  552. this.params[prop][i].supplierName2 = rows[j]
  553. }
  554. // this.$refs.table.doLayout()
  555. console.log(this.params[prop])
  556. this.$modal.closeLoading();
  557. }
  558. } else if(scope.column.property == 'bidPrice2') {
  559. console.log('复制内容:', rows)
  560. let newLine = []
  561. const {TabColumns} = this;
  562. const {TableColumns} = TabColumns.find(
  563. ({item: {key}}) => key === prop
  564. );
  565. if(this.params[prop].length <= 1) {
  566. for (let i = 0; i<rows.length; i++) {
  567. let line = {...this.$init.params(TableColumns)}
  568. line.bidPrice2 = rows[i]
  569. newLine.push(line)
  570. }
  571. // 删除指定下标
  572. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  573. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  574. // this.$refs.table.doLayout()
  575. this.$modal.closeLoading();
  576. } else {
  577. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  578. this.params[prop][i].bidPrice2 = rows[j]
  579. }
  580. // this.$refs.table.doLayout()
  581. console.log(this.params[prop])
  582. this.$modal.closeLoading();
  583. }
  584. } else if(scope.column.property == 'unitPrice2') {
  585. console.log('复制内容:', rows)
  586. let newLine = []
  587. const {TabColumns} = this;
  588. const {TableColumns} = TabColumns.find(
  589. ({item: {key}}) => key === prop
  590. );
  591. if(this.params[prop].length <= 1) {
  592. for (let i = 0; i<rows.length; i++) {
  593. let line = {...this.$init.params(TableColumns)}
  594. line.unitPrice2 = rows[i]
  595. newLine.push(line)
  596. }
  597. // 删除指定下标
  598. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  599. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  600. // this.$refs.table.doLayout()
  601. this.$modal.closeLoading();
  602. } else {
  603. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  604. this.params[prop][i].unitPrice2 = rows[j]
  605. }
  606. // this.$refs.table.doLayout()
  607. console.log(this.params[prop])
  608. this.$modal.closeLoading();
  609. }
  610. }
  611. } else {
  612. this.$modal.notifyWarning("复制长度不能超过100!");
  613. this.$modal.closeLoading();
  614. }
  615. },
  616. },
  617. created() {
  618. },
  619. mounted() {
  620. },
  621. destroyed() {
  622. },
  623. };
  624. </script>
  625. <template>
  626. <el-button v-bind="$attrs" v-on="$listeners" @click="onOpen">
  627. {{ title }}
  628. <el-drawer
  629. :show-close="false"
  630. :size="width"
  631. :title="title"
  632. :visible.sync="visible"
  633. append-to-body
  634. destroy-on-close
  635. @close="onHide"
  636. >
  637. <template slot="title">
  638. <span>{{ title }}</span>
  639. <el-button
  640. type="primary"
  641. :size="$attrs.size"
  642. :loading="loading"
  643. @click="useSubmit('superForm')"
  644. >
  645. 确 认
  646. </el-button>
  647. <el-button :size="$attrs.size" :loading="loading" @click="onHide">
  648. 取 消
  649. </el-button>
  650. </template>
  651. <el-super-form
  652. v-model="params"
  653. :dict="dict"
  654. :rules="rules"
  655. :size="$attrs.size"
  656. :columns="TableColumns"
  657. ref="superForm"
  658. label-width="auto"
  659. label-position="right"
  660. style="padding: 18px"
  661. >
  662. </el-super-form>
  663. <el-tabs v-model="tabName" style="padding: 0 18px 18px">
  664. <el-tab-pane
  665. v-for="({ item, TableColumns: columns }, index) in TabColumns"
  666. :key="index"
  667. :label="item.title"
  668. :name="item.key"
  669. lazy
  670. >
  671. <div v-loading="loading" style="height: 250px; display: flex">
  672. <el-super-ux-table
  673. v-model="params[item.key]"
  674. :dict="dict"
  675. :ref="tabName"
  676. height="250"
  677. :columns="columns"
  678. :size="$attrs.size"
  679. >
  680. <template slot="materialName" slot-scope="scope">
  681. <component
  682. v-bind="scope.attr"
  683. v-model="scope.row[scope.item.key]"
  684. :size="$attrs.size"
  685. :source.sync="scope.row"
  686. @change="changeMaterialName({ ...scope, selectData: $event })"
  687. >
  688. </component>
  689. </template>
  690. <template slot="materialCode" slot-scope="scope">
  691. <component
  692. v-bind="scope.attr"
  693. v-model="scope.row[scope.item.key]"
  694. :size="$attrs.size"
  695. :source.sync="scope.row"
  696. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  697. >
  698. </component>
  699. </template>
  700. <template slot="taxPrice" slot-scope="scope">
  701. <component
  702. v-bind="scope.attr"
  703. v-model="scope.row[scope.item.key]"
  704. :size="$attrs.size"
  705. :source.sync="scope.row"
  706. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  707. >
  708. </component>
  709. </template>
  710. <template slot="supplierName" slot-scope="scope">
  711. <component
  712. v-bind="scope.attr"
  713. v-model="scope.row[scope.item.key]"
  714. :size="$attrs.size"
  715. :source.sync="scope.row"
  716. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  717. >
  718. </component>
  719. </template>
  720. <template slot="bidPrice" slot-scope="scope">
  721. <component
  722. v-bind="scope.attr"
  723. v-model="scope.row[scope.item.key]"
  724. :size="$attrs.size"
  725. :source.sync="scope.row"
  726. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  727. >
  728. </component>
  729. </template>
  730. <template slot="unitPrice" slot-scope="scope">
  731. <component
  732. v-bind="scope.attr"
  733. v-model="scope.row[scope.item.key]"
  734. :size="$attrs.size"
  735. :source.sync="scope.row"
  736. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  737. >
  738. </component>
  739. </template>
  740. <template slot="supplierName1" slot-scope="scope">
  741. <component
  742. v-bind="scope.attr"
  743. v-model="scope.row[scope.item.key]"
  744. :size="$attrs.size"
  745. :source.sync="scope.row"
  746. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  747. >
  748. </component>
  749. </template>
  750. <template slot="bidPrice1" slot-scope="scope">
  751. <component
  752. v-bind="scope.attr"
  753. v-model="scope.row[scope.item.key]"
  754. :size="$attrs.size"
  755. :source.sync="scope.row"
  756. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  757. >
  758. </component>
  759. </template>
  760. <template slot="unitPrice1" slot-scope="scope">
  761. <component
  762. v-bind="scope.attr"
  763. v-model="scope.row[scope.item.key]"
  764. :size="$attrs.size"
  765. :source.sync="scope.row"
  766. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  767. >
  768. </component>
  769. </template>
  770. <template slot="supplierName2" slot-scope="scope">
  771. <component
  772. v-bind="scope.attr"
  773. v-model="scope.row[scope.item.key]"
  774. :size="$attrs.size"
  775. :source.sync="scope.row"
  776. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  777. >
  778. </component>
  779. </template>
  780. <template slot="bidPrice2" slot-scope="scope">
  781. <component
  782. v-bind="scope.attr"
  783. v-model="scope.row[scope.item.key]"
  784. :size="$attrs.size"
  785. :source.sync="scope.row"
  786. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  787. >
  788. </component>
  789. </template>
  790. <template slot="unitPrice2" slot-scope="scope">
  791. <component
  792. v-bind="scope.attr"
  793. v-model="scope.row[scope.item.key]"
  794. :size="$attrs.size"
  795. :source.sync="scope.row"
  796. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  797. >
  798. </component>
  799. </template>
  800. <template slot="customerName" slot-scope="scope">
  801. <component
  802. v-bind="scope.attr"
  803. v-model="scope.row[scope.item.key]"
  804. :size="$attrs.size"
  805. :source.sync="scope.row"
  806. @input="changeCustomerName({ ...scope, selectData: $event })"
  807. >
  808. </component>
  809. </template>
  810. <ux-table-column fixed="right" label="操作" width="100">
  811. <template slot="header" slot-scope="scope">
  812. <el-button
  813. type="text"
  814. :size="$attrs.size"
  815. @click="onRowAdd(tabName)"
  816. >
  817. 新增
  818. </el-button>
  819. </template>
  820. <template slot-scope="scope">
  821. <el-button
  822. type="text"
  823. :size="$attrs.size"
  824. @click.native.prevent="onRowRemove(tabName, scope)"
  825. >
  826. 删除
  827. </el-button>
  828. </template>
  829. </ux-table-column>
  830. </el-super-ux-table>
  831. </div>
  832. </el-tab-pane>
  833. </el-tabs>
  834. </el-drawer>
  835. </el-button>
  836. </template>
  837. <style scoped></style>