index.vue 32 KB

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