detailsPage.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. >返回列表
  11. </el-button>
  12. </div>
  13. <div class="add-customer-btn" v-if="showBut" size="small">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. v-if="detailData.status == 1"
  18. class="el-button--small-yh "
  19. @click.stop="openEdit"
  20. >编辑
  21. </el-button>
  22. <el-dropdown style="margin-right: 8px;margin-left: 8px;">
  23. <el-button type="primary" size="small">
  24. 审核处理<i class="el-icon-arrow-down el-icon--right"></i>
  25. </el-button>
  26. <el-dropdown-menu slot="dropdown">
  27. <el-dropdown-item
  28. :disabled="form.status > 0"
  29. @click.native="pleaseCheck"
  30. >请核数据</el-dropdown-item
  31. >
  32. <el-dropdown-item disabled>审核进度</el-dropdown-item>
  33. <el-dropdown-item disabled>撤销请核</el-dropdown-item>
  34. </el-dropdown-menu>
  35. </el-dropdown>
  36. <el-dropdown style="margin-right: 8px;">
  37. <el-button type="warning" size="small">
  38. 账单处理<i class="el-icon-arrow-down el-icon--right"></i>
  39. </el-button>
  40. <el-dropdown-menu slot="dropdown">
  41. <el-dropdown-item @click.native="generateBill" :disabled="!form.id"
  42. >申请货款</el-dropdown-item
  43. >
  44. <el-dropdown-item @click.native="viewBill" :disabled="!form.id"
  45. >查看货款</el-dropdown-item
  46. >
  47. </el-dropdown-menu>
  48. </el-dropdown>
  49. <el-dropdown style="margin-right: 8px;">
  50. <el-button type="success" size="small">
  51. 业务处理<i class="el-icon-arrow-down el-icon--right"></i>
  52. </el-button>
  53. <el-dropdown-menu slot="dropdown">
  54. <el-dropdown-item :disabled="!form.id" @click.native="copyDoc"
  55. >复制单据</el-dropdown-item
  56. >
  57. </el-dropdown-menu>
  58. </el-dropdown>
  59. <el-button
  60. type="primary"
  61. :disabled="disabled"
  62. @click="editCustomer"
  63. :loading="subLoading"
  64. v-if="detailData.status != 1"
  65. size="small"
  66. >保存数据
  67. </el-button>
  68. </div>
  69. </div>
  70. <div class="customer-main">
  71. <trade-card title="基础信息">
  72. <avue-form
  73. ref="form"
  74. class="trading-form"
  75. v-model="form"
  76. :option="option"
  77. >
  78. <template slot="corpId">
  79. <crop-select
  80. v-model="form.corpId"
  81. corpType="GYS"
  82. :disabled="detailData.status == 1"
  83. ></crop-select>
  84. </template>
  85. <template slot="exchangeRate">
  86. <el-input
  87. size="mini"
  88. v-model="form.exchangeRate"
  89. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  90. @change="rateChange"
  91. placeholder="请输入 汇率"
  92. :disabled="detailData.status == 1"
  93. ><template slot="append">%</template></el-input
  94. >
  95. </template>
  96. <template slot="orderNo">
  97. <el-input
  98. size="mini"
  99. v-model="form.orderNo"
  100. oninput="this.value=this.value.toUpperCase()"
  101. placeholder="请输入 "
  102. :disabled="detailData.status == 1"
  103. />
  104. </template>
  105. </avue-form>
  106. </trade-card>
  107. <div>
  108. <trade-card title="商品信息">
  109. <avue-crud
  110. ref="crud"
  111. :data="data"
  112. :option="tableOption"
  113. @row-del="rowDel"
  114. @selection-change="goodsSelectionChange"
  115. @saveColumn="saveColumn"
  116. @resetColumn="resetColumn"
  117. :summary-method="summaryMethod"
  118. :cell-style="cellStyle"
  119. >
  120. <template slot="price" slot-scope="{ row }">
  121. <el-input
  122. v-if="row.$cellEdit"
  123. v-model="row.price"
  124. size="small"
  125. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  126. @change="priceChange(row)"
  127. ></el-input>
  128. <span v-else>{{ row.price }}</span>
  129. </template>
  130. <template slot="orderQuantity" slot-scope="{ row }">
  131. <el-input
  132. v-if="row.$cellEdit"
  133. v-model="row.orderQuantity"
  134. size="small"
  135. oninput='this.value=this.value.replace(/[^(\d)]/g,"")'
  136. @change="quantityChange(row)"
  137. ></el-input>
  138. <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
  139. </template>
  140. <template slot="cname" slot-scope="{ row, index }">
  141. <el-button
  142. size="small"
  143. type="text"
  144. @click="rePick(row, index)"
  145. :disabled="disabled || detailData.status == 1"
  146. class="picker"
  147. style="padding:4px 10px;float:left"
  148. >选择</el-button
  149. >
  150. <span>{{ row.cname }}</span>
  151. </template>
  152. <template slot="itemType" slot-scope="{ row }">
  153. <el-select
  154. v-if="row.$cellEdit"
  155. v-model="row.itemType"
  156. filterable
  157. allow-create
  158. default-first-option
  159. placeholder="请输入"
  160. @focus="itemTypeFocus(row)"
  161. size="small"
  162. >
  163. <el-option
  164. v-for="(item, index) in itemtypeList"
  165. :key="index"
  166. :label="item.value"
  167. :value="item.value"
  168. >
  169. </el-option>
  170. </el-select>
  171. <span v-else>{{ row.itemType }}</span>
  172. </template>
  173. <template slot="menuLeft">
  174. <el-button
  175. type="primary"
  176. icon="el-icon-plus"
  177. size="small"
  178. @click.stop="newDetails"
  179. :disabled="detailData.status == 1"
  180. >录入明细</el-button
  181. >
  182. <el-button
  183. type="info"
  184. icon="el-icon-printer"
  185. size="small"
  186. @click.stop="openReport()"
  187. >报表打印</el-button
  188. >
  189. <el-button
  190. type="warning"
  191. icon="el-icon-plus"
  192. size="small"
  193. :disabled="detailData.status == 1 || orderItemIds.length == 0"
  194. @click="getInvoice"
  195. >生成收货单
  196. </el-button>
  197. </template>
  198. <template slot="menu" slot-scope="{ row, index }">
  199. <el-button
  200. size="small"
  201. icon="el-icon-edit"
  202. type="text"
  203. @click="rowCell(row, index)"
  204. :disabled="disabled || detailData.status == 1"
  205. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  206. >
  207. <el-button
  208. size="small"
  209. icon="el-icon-edit"
  210. type="text"
  211. @click="rowDel(row)"
  212. :disabled="detailData.status == 1"
  213. >删 除</el-button
  214. >
  215. </template>
  216. </avue-crud>
  217. </trade-card>
  218. </div>
  219. <fee-info
  220. ref="feeInfo"
  221. :orderFeesList="orderFeesList"
  222. :disabled="detailData.status == 1"
  223. feeUrl="/trade-purchase/purchase-order/removeByFees"
  224. optionType="CK"
  225. itemType="采购"
  226. @beforeFinance="beforeFinance"
  227. :inCropId="true"
  228. />
  229. <containerTitle title="合同附件"></containerTitle>
  230. <c-upload
  231. typeUpload="CK"
  232. :data="orderFilesList"
  233. :disabled="detailData.status == 1"
  234. :enumerationValue="76"
  235. deleteUrl="/trade-purchase/purchase-order/removeByFiles"
  236. />
  237. <div>
  238. <trade-card title="银行信息">
  239. <avue-form
  240. class="trading-form"
  241. ref="form"
  242. v-model="form"
  243. :option="bankOption"
  244. />
  245. </trade-card>
  246. </div>
  247. </div>
  248. <el-dialog
  249. title="账单"
  250. append-to-body
  251. class="el-dialogDeep"
  252. :visible.sync="financialAccountDialog"
  253. width="60%"
  254. :close-on-click-modal="false"
  255. :destroy-on-close="true"
  256. :close-on-press-escape="false"
  257. v-dialog-drag
  258. >
  259. <financial-account
  260. billType="申请"
  261. :billData="billData"
  262. itemType="采购"
  263. @choceFun="choceFun"
  264. >
  265. </financial-account>
  266. </el-dialog>
  267. <el-dialog
  268. title="申请记录"
  269. append-to-body
  270. class="el-dialogDeep"
  271. :visible.sync="applicationDialog"
  272. width="60%"
  273. :close-on-click-modal="false"
  274. :destroy-on-close="true"
  275. :close-on-press-escape="false"
  276. v-dialog-drag
  277. >
  278. <bill-application :billId="form.id" @choceApplication="choceApplication">
  279. </bill-application>
  280. </el-dialog>
  281. <el-dialog
  282. title="导入商品"
  283. append-to-body
  284. class="el-dialogDeep"
  285. :visible.sync="dialogVisible"
  286. width="80%"
  287. :close-on-click-modal="false"
  288. :destroy-on-close="true"
  289. :close-on-press-escape="false"
  290. @close="closeGoods"
  291. top="5vh"
  292. v-dialog-drag
  293. >
  294. <span>
  295. <el-row>
  296. <el-col :span="4">
  297. <div>
  298. <el-scrollbar>
  299. <basic-container>
  300. <avue-tree
  301. :option="treeOption"
  302. @node-click="nodeClick"
  303. :style="treeStyle"
  304. />
  305. </basic-container>
  306. </el-scrollbar>
  307. </div>
  308. </el-col>
  309. <el-col :span="20">
  310. <avue-crud
  311. :option="goodsOption"
  312. :table-loading="loading"
  313. :data="goodsList"
  314. ref="goodsCrud"
  315. :search.sync="search"
  316. @search-change="searchChange"
  317. @refresh-change="refreshChange"
  318. @selection-change="selectionChange"
  319. @row-click="rowClick"
  320. :page.sync="page"
  321. @on-load="onLoad"
  322. @saveColumn="saveGoodsColumn"
  323. @resetColumn="resetGoodsColumn"
  324. :cell-style="cellStyle"
  325. ></avue-crud>
  326. </el-col>
  327. </el-row>
  328. </span>
  329. <span slot="footer" class="dialog-footer">
  330. <el-button @click="dialogVisible = false">取 消</el-button>
  331. <el-button
  332. type="primary"
  333. @click="importGoods"
  334. :disabled="selectionList.length == 0"
  335. >导入</el-button
  336. >
  337. </span>
  338. </el-dialog>
  339. <report-dialog
  340. :switchDialog="switchDialog"
  341. :reportId="form.id"
  342. reportName="客户询价"
  343. @onClose="onClose()"
  344. ></report-dialog>
  345. </div>
  346. </template>
  347. <script>
  348. import tableOption from "./config/customerContact.json";
  349. import goodsOption from "./config/commodity.json";
  350. import feeInfo from "@/components/fee-info/main";
  351. import uploadFile from "@/components/upload-file/main";
  352. import {
  353. detail,
  354. submit,
  355. delItem,
  356. getDeptLazyTree,
  357. getGoods,
  358. getSpecification,
  359. pleaseCheck
  360. } from "@/api/exportTrade/purchaseContract";
  361. import _ from "lodash";
  362. import reportDialog from "@/components/report-dialog/main";
  363. import { contrastObj, contrastList } from "@/util/contrastData";
  364. import {
  365. isvalidatemobile,
  366. validatename,
  367. micrometerFormat,
  368. IntegerFormat
  369. } from "@/util/validate";
  370. import financialAccount from "@/components/finance/financialAccount";
  371. import billApplication from "@/components/bill/billApplication";
  372. export default {
  373. name: "detailsPageEdit",
  374. data() {
  375. return {
  376. billData: {}, //账单需要数据
  377. financialAccountDialog: false,
  378. applicationDialog: false,
  379. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  380. switchDialog: false,
  381. form: {
  382. orderStatus: "录入"
  383. },
  384. disabled: false,
  385. dialogVisible: false,
  386. tableOption: tableOption,
  387. option: {
  388. menuBtn: false,
  389. labelWidth: 100,
  390. disabled: false,
  391. column: [
  392. {
  393. label: "供应商",
  394. prop: "corpId",
  395. rules: [
  396. {
  397. required: true,
  398. message: "",
  399. trigger: "blur"
  400. }
  401. ],
  402. span: 16,
  403. slot: true
  404. },
  405. {
  406. label: "系统号",
  407. prop: "sysNo",
  408. span: 8,
  409. disabled: true
  410. },
  411. {
  412. label: "联系人",
  413. prop: "corpAttn",
  414. span: 8
  415. },
  416. {
  417. label: "电话",
  418. prop: "corpTel",
  419. span: 8
  420. },
  421. {
  422. label: "订单状态",
  423. prop: "orderStatus",
  424. span: 8,
  425. type: "select",
  426. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  427. props: {
  428. label: "dictValue",
  429. value: "dictValue"
  430. }
  431. },
  432. {
  433. label: "采购日期",
  434. prop: "businesDate",
  435. span: 8,
  436. type: "date",
  437. format: "yyyy-MM-dd",
  438. valueFormat: "yyyy-MM-dd 00:00:00",
  439. rules: [
  440. {
  441. required: true,
  442. message: "",
  443. trigger: "blur"
  444. }
  445. ]
  446. },
  447. {
  448. label: "预交日期",
  449. prop: "plannedDeliveryDate",
  450. span: 8,
  451. type: "date",
  452. format: "yyyy-MM-dd",
  453. valueFormat: "yyyy-MM-dd 00:00:00"
  454. },
  455. {
  456. label: "实交日期",
  457. prop: "requiredDeliveryDate",
  458. span: 8,
  459. type: "date",
  460. format: "yyyy-MM-dd",
  461. valueFormat: "yyyy-MM-dd 00:00:00"
  462. },
  463. {
  464. label: "是否开票",
  465. prop: "ifInvoice",
  466. span: 8,
  467. type: "select",
  468. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  469. props: {
  470. label: "dictValue",
  471. value: "dictValue"
  472. }
  473. },
  474. {
  475. label: "付款方式",
  476. prop: "paymentType",
  477. span: 8,
  478. type: "select",
  479. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  480. props: {
  481. label: "dictValue",
  482. value: "dictValue"
  483. }
  484. },
  485. {
  486. label: "付款说明",
  487. prop: "paymentTypeDescription",
  488. span: 8
  489. },
  490. {
  491. label: "采购订单号",
  492. prop: "orderNo",
  493. span: 8
  494. },
  495. {
  496. label: "币别",
  497. prop: "currency",
  498. span: 8,
  499. type: "select",
  500. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  501. props: {
  502. label: "dictValue",
  503. value: "dictValue"
  504. },
  505. change: ({ value }) => {
  506. if (value == "CNY") {
  507. this.form.exchangeRate = 1;
  508. }
  509. if (value == "USD") {
  510. this.form.exchangeRate = 6.3843;
  511. }
  512. }
  513. },
  514. {
  515. label: "汇率",
  516. prop: "exchangeRate",
  517. span: 8,
  518. slot: true,
  519. row: true,
  520. disabled: true
  521. },
  522. {
  523. label: "备注",
  524. prop: "orderRemark",
  525. type: "textarea",
  526. minRows: 2,
  527. span: 24
  528. }
  529. ]
  530. },
  531. treeOption: {
  532. nodeKey: "id",
  533. lazy: true,
  534. treeLoad: function(node, resolve) {
  535. const parentId = node.level === 0 ? 0 : node.data.id;
  536. getDeptLazyTree(parentId).then(res => {
  537. resolve(
  538. res.data.data.map(item => {
  539. return {
  540. ...item,
  541. leaf: !item.hasChildren
  542. };
  543. })
  544. );
  545. });
  546. },
  547. addBtn: false,
  548. menu: false,
  549. size: "small",
  550. props: {
  551. label: "title",
  552. value: "value",
  553. children: "children"
  554. }
  555. },
  556. bankOption: {
  557. menuBtn: false,
  558. labelWidth: 100,
  559. column: [
  560. {
  561. label: "银行",
  562. prop: "banks",
  563. span: 8
  564. },
  565. {
  566. label: "银行信息",
  567. prop: "banksAccountName",
  568. span: 16,
  569. type: "textarea",
  570. minRows: 2
  571. }
  572. ]
  573. },
  574. insuranceOption: {
  575. menuBtn: false,
  576. labelWidth: 100,
  577. column: [
  578. {
  579. label: "保险描述",
  580. prop: "insuranceRemarks",
  581. span: 24,
  582. type: "textarea",
  583. minRows: 2
  584. }
  585. ]
  586. },
  587. markOption: {
  588. menuBtn: false,
  589. labelWidth: 100,
  590. column: [
  591. {
  592. label: "唛头描述",
  593. prop: "marks",
  594. span: 24,
  595. type: "textarea",
  596. minRows: 2
  597. }
  598. ]
  599. },
  600. page: {
  601. pageSize: 10,
  602. currentPage: 1,
  603. total: 0
  604. },
  605. loading: false,
  606. goodsOption: {},
  607. data: [],
  608. goodsList: [],
  609. selectionList: [],
  610. treeDeptId: null,
  611. orderFeesList: [],
  612. orderFilesList: [],
  613. orderItemIds: [],
  614. itemtypeList: [],
  615. goodsSelections: [],
  616. reData: null,
  617. oldform: {
  618. orderStatus: "录入"
  619. },
  620. olddata: [],
  621. oldorderFeesList: [],
  622. oldorderFilesList: [],
  623. subLoading: false,
  624. pageLoading: false,
  625. showBut: true,
  626. search: {}
  627. };
  628. },
  629. props: {
  630. detailData: {
  631. type: Object
  632. }
  633. },
  634. components: {
  635. reportDialog,
  636. feeInfo,
  637. uploadFile,
  638. financialAccount,
  639. billApplication
  640. },
  641. async created() {
  642. if (this.detailData.id) {
  643. this.getDetail(this.detailData.id);
  644. }
  645. this.tableOption = await this.getColumnData(
  646. this.getColumnName(3),
  647. tableOption
  648. );
  649. this.goodsOption = await this.getColumnData(
  650. this.getColumnName(27),
  651. goodsOption
  652. );
  653. if (this.detailData.status == 1) {
  654. this.option.disabled = true;
  655. this.bankOption.disabled = true;
  656. this.insuranceOption.disabled = true;
  657. this.markOption.disabled = true;
  658. }
  659. this.getWorkDicts("product_properties").then(res => {
  660. this.findObject(this.tableOption.column, "itemProp").dicData =
  661. res.data.data;
  662. });
  663. this.getWorkDicts("unit").then(res => {
  664. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  665. });
  666. },
  667. filters: {
  668. IntegerFormat(num) {
  669. return IntegerFormat(num);
  670. }
  671. },
  672. methods: {
  673. cellStyle() {
  674. return "padding:0;height:40px;";
  675. },
  676. copyDoc() {
  677. this.$emit("copyOrder", this.form.id);
  678. },
  679. rePick(row, index) {
  680. this.reData = {
  681. ...row,
  682. index: index
  683. };
  684. this.newDetails();
  685. },
  686. rowCell(row, index) {
  687. if (row.$cellEdit == true) {
  688. this.$set(row, "$cellEdit", false);
  689. } else {
  690. this.$set(row, "$cellEdit", true);
  691. }
  692. },
  693. itemTypeFocus(row) {
  694. this.itemtypeList = [];
  695. getSpecification({ goodId: row.itemId }).then(res => {
  696. const data = res.data.data;
  697. this.itemtypeList = data.map(item => ({ value: item }));
  698. });
  699. },
  700. priceChange(row) {
  701. console.log(row);
  702. if (!row.price) {
  703. row.price = 0;
  704. } else {
  705. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  706. }
  707. },
  708. quantityChange(row) {
  709. if (Number(row.orderQuantity) < Number(row.actualQuantity)) {
  710. row.orderQuantity = row.actualQuantity;
  711. this.$message.error("修改的数量不能低于已收数量");
  712. }
  713. if (!row.orderQuantity) {
  714. row.orderQuantity = 0;
  715. } else {
  716. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  717. }
  718. },
  719. rowSave(row) {
  720. console.log(row);
  721. this.$set(row, "$cellEdit", false);
  722. },
  723. rowDel(row) {
  724. this.$confirm("确定删除数据?", {
  725. confirmButtonText: "确定",
  726. cancelButtonText: "取消",
  727. type: "warning"
  728. }).then(() => {
  729. if (row.id) {
  730. delItem(row.id).then(res => {
  731. this.$message({
  732. type: "success",
  733. message: "删除成功!"
  734. });
  735. this.data.splice(row.$index, 1);
  736. });
  737. } else {
  738. this.$message({
  739. type: "success",
  740. message: "删除成功!"
  741. });
  742. this.data.splice(row.$index, 1);
  743. }
  744. });
  745. },
  746. importGoods() {
  747. if (this.reData) {
  748. console.log(this.reData);
  749. if (this.selectionList.length != 1) {
  750. return this.$message.error("重新选择的时候只能选择一条数据");
  751. } else {
  752. this.selectionList.forEach(e => {
  753. this.data.forEach((item, index) => {
  754. if (index == this.reData.index) {
  755. item.itemId = e.id;
  756. item.code = e.code;
  757. item.cname = e.cname;
  758. item.priceCategory = e.goodsTypeName;
  759. item.itemUrl = e.url;
  760. item.itemProp = this.reData.itemProp;
  761. item.itemDescription = e.cnameDescription;
  762. item.itemType = this.reData.itemType;
  763. item.tradeTerms = this.reData.tradeTerms;
  764. item.price = this.reData.price;
  765. item.orderQuantity = this.reData.orderQuantity;
  766. item.insurance = this.reData.insurance;
  767. item.freight = this.reData.freight;
  768. item.discount = this.reData.discount;
  769. item.amount = this.reData.amount;
  770. item.taxRate = this.reData.taxRate;
  771. item.unit = e.unit;
  772. item.remarks = this.reData.remarks;
  773. item.$cellEdit = true;
  774. }
  775. });
  776. });
  777. }
  778. } else {
  779. this.selectionList.forEach(e => {
  780. this.data.push({
  781. itemId: e.id,
  782. code: e.code,
  783. cname: e.cname,
  784. priceCategory: e.goodsTypeName,
  785. itemUrl: e.url,
  786. itemProp: null,
  787. itemDescription: e.cnameDescription,
  788. itemType: null,
  789. tradeTerms: null,
  790. price: 0,
  791. orderQuantity: 0,
  792. insurance: 0,
  793. freight: 0,
  794. discount: null,
  795. amount: 0,
  796. taxRate: 0,
  797. unit: e.unit,
  798. remarks: null,
  799. $cellEdit: true
  800. });
  801. });
  802. }
  803. this.dialogVisible = false;
  804. },
  805. closeGoods() {
  806. this.selectionList = [];
  807. this.treeDeptId = "";
  808. this.reData = null;
  809. },
  810. goodsSelectionChange(list) {
  811. this.goodsSelections = list;
  812. this.orderItemIds = [];
  813. list.map(e => {
  814. this.orderItemIds.push(e.id);
  815. });
  816. },
  817. selectionChange(list) {
  818. this.selectionList = list;
  819. },
  820. rowClick(row) {
  821. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  822. },
  823. nodeClick(data) {
  824. this.treeDeptId = data.id;
  825. this.page.currentPage = 1;
  826. this.onLoad(this.page);
  827. },
  828. searchChange(params, done) {
  829. this.search = this.deepClone(params);
  830. this.onLoad(this.page, params);
  831. done();
  832. },
  833. //费用查询
  834. onLoad(page, params = {}) {
  835. let obj = this.deepClone(Object.assign(params, this.search));
  836. this.loading = true;
  837. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj).then(
  838. res => {
  839. const data = res.data.data;
  840. this.page.total = data.total;
  841. this.goodsList = data.records;
  842. this.loading = false;
  843. if (this.page.total) {
  844. this.goodsOption.height = window.innerHeight - 350;
  845. }
  846. }
  847. );
  848. },
  849. //商品明细导入
  850. newDetails() {
  851. this.dialogVisible = !this.dialogVisible;
  852. },
  853. getDetail(id) {
  854. this.showBut = false;
  855. this.pageLoading = true;
  856. detail(id)
  857. .then(res => {
  858. if (this.detailData.status == "copy") {
  859. delete res.data.data.id;
  860. delete res.data.data.sysNo;
  861. delete res.data.data.orderNo;
  862. delete res.data.data.orgOrderNo;
  863. delete res.data.data.createTime;
  864. delete res.data.data.createUser;
  865. delete res.data.data.createUserName;
  866. delete res.data.data.updateTime;
  867. delete res.data.data.updateUser;
  868. delete res.data.data.updateUserName;
  869. delete res.data.data.morderNo;
  870. delete res.data.data.status;
  871. delete res.data.data.ifEnquiry;
  872. delete res.data.data.ifShipping;
  873. res.data.data.orderStatus = "录入";
  874. if (res.data.data.itemsVOList) {
  875. res.data.data.itemsVOList.forEach(e => {
  876. delete e.id;
  877. delete e.pid;
  878. delete e.createTime;
  879. delete e.createUser;
  880. delete e.updateTime;
  881. delete e.updateUser;
  882. delete e.orgOrderNo;
  883. delete e.srcId;
  884. delete e.status;
  885. delete e.isDeleted;
  886. });
  887. }
  888. if (res.data.data.orderFeesList) {
  889. res.data.data.orderFeesList.forEach(e => {
  890. delete e.id;
  891. delete e.pid;
  892. delete e.createTime;
  893. delete e.createUser;
  894. delete e.updateTime;
  895. delete e.updateUser;
  896. delete e.status;
  897. delete e.isDeleted;
  898. });
  899. }
  900. if (res.data.data.orderFilesList) {
  901. res.data.data.orderFilesList.forEach(e => {
  902. delete e.id;
  903. delete e.pid;
  904. delete e.createTime;
  905. delete e.createUser;
  906. delete e.updateTime;
  907. delete e.updateUser;
  908. delete e.status;
  909. delete e.isDeleted;
  910. });
  911. }
  912. }
  913. this.form = res.data.data;
  914. this.data = res.data.data.itemsVOList
  915. ? res.data.data.itemsVOList
  916. : [];
  917. this.orderFeesList = res.data.data.orderFeesList
  918. ? res.data.data.orderFeesList
  919. : [];
  920. this.orderFilesList = res.data.data.orderFilesList
  921. ? res.data.data.orderFilesList
  922. : [];
  923. this.oldform = res.data.data;
  924. this.olddata = this.deepClone(
  925. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  926. );
  927. this.oldorderFeesList = this.deepClone(
  928. res.data.data.orderFeesList ? res.data.data.orderFeesList : []
  929. );
  930. this.oldorderFilesList = this.deepClone(
  931. res.data.data.orderFilesList ? res.data.data.orderFilesList : []
  932. );
  933. })
  934. .finally(() => {
  935. this.showBut = true;
  936. this.pageLoading = false;
  937. });
  938. },
  939. //修改提交触发
  940. editCustomer(status) {
  941. this.$refs["form"].validate((valid, done) => {
  942. done();
  943. if (valid) {
  944. const orderFeesList = this.$refs.feeInfo.submitData();
  945. for (let i = 0; i < orderFeesList.length; i++) {
  946. // if (orderFeesList[i].corpId == null) {
  947. // return this.$message.error(`请输入第${i + 1}行的结算中心`);
  948. // }
  949. if (orderFeesList[i].price == 0) {
  950. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  951. }
  952. if (orderFeesList[i].quantity == 0) {
  953. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  954. }
  955. }
  956. this.subLoading = true;
  957. submit({
  958. ...this.form,
  959. itemsVOList: this.data,
  960. orderFeesList: orderFeesList,
  961. orderFilesList: this.orderFilesList,
  962. tradeType: "CK",
  963. billType: "CG"
  964. })
  965. .then(res => {
  966. this.$message.success("保存成功");
  967. this.getDetail(res.data.data);
  968. if (status == "goBack") {
  969. if (this.form.id) {
  970. this.unLock({
  971. moduleName: "cg",
  972. tableName: "business_order",
  973. billId: this.form.id,
  974. billNo: this.form.orgOrderNo
  975. });
  976. }
  977. this.$emit("goBack");
  978. this.leaveDetailsKey(this.$route.name);
  979. }
  980. })
  981. .finally(() => {
  982. this.subLoading = false;
  983. });
  984. } else {
  985. return false;
  986. }
  987. });
  988. },
  989. generateBill() {
  990. this.financialAccountDialog = true;
  991. this.billData = {
  992. srcOrderno: this.form.orgOrderNo,
  993. itemType: "销售",
  994. corpsName: this.form.corpName,
  995. corpId: this.form.corpId,
  996. srcParentId: this.form.id,
  997. currency: "CNY",
  998. exchangeRate: "1",
  999. taxRate: "0",
  1000. accDate: this.form.businesDate,
  1001. srcType: 1,
  1002. tradeType: "CK",
  1003. optionType: "CK"
  1004. };
  1005. },
  1006. choceFun() {
  1007. this.financialAccountDialog = false;
  1008. },
  1009. viewBill() {
  1010. this.applicationDialog = true;
  1011. },
  1012. //关闭记录
  1013. choceApplication() {
  1014. this.applicationDialog = false;
  1015. },
  1016. // 请核
  1017. pleaseCheck() {
  1018. this.$confirm("您确定提交此次申请吗?", {
  1019. confirmButtonText: "确定",
  1020. cancelButtonText: "取消",
  1021. type: "warning"
  1022. }).then(() => {
  1023. const data = {
  1024. id: this.form.id,
  1025. checkType: "cgqh",
  1026. url: "/exportTrade/purchaseContract/index",
  1027. pageStatus: "this.$store.getters.domPurStatus",
  1028. pageLabel: "采购(E)",
  1029. checkFlag: 2
  1030. };
  1031. pleaseCheck(data).then(res => {
  1032. this.$message.success("请核成功");
  1033. this.getDetail(this.form.id);
  1034. });
  1035. });
  1036. },
  1037. //返回列表
  1038. backToList() {
  1039. let orderFeesList = this.$refs.feeInfo.submitData();
  1040. if (
  1041. contrastObj(this.form, this.oldform) ||
  1042. contrastList(this.data, this.olddata) ||
  1043. contrastList(orderFeesList, this.oldorderFeesList) ||
  1044. contrastList(this.orderFilesList, this.oldorderFilesList)
  1045. ) {
  1046. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  1047. confirmButtonText: "确定",
  1048. cancelButtonText: "取消",
  1049. type: "warning"
  1050. })
  1051. .then(() => {
  1052. this.editCustomer("goBack");
  1053. })
  1054. .catch(() => {
  1055. if (this.form.id) {
  1056. this.unLock({
  1057. moduleName: "cg",
  1058. tableName: "business_order",
  1059. billId: this.form.id,
  1060. billNo: this.form.orgOrderNo
  1061. });
  1062. }
  1063. this.$emit("goBack");
  1064. this.leaveDetailsKey(this.$route.name);
  1065. });
  1066. } else {
  1067. if (this.form.id) {
  1068. this.unLock({
  1069. moduleName: "cg",
  1070. tableName: "business_order",
  1071. billId: this.form.id,
  1072. billNo: this.form.orgOrderNo
  1073. });
  1074. }
  1075. this.$emit("goBack");
  1076. this.leaveDetailsKey(this.$route.name);
  1077. }
  1078. },
  1079. openReport() {
  1080. this.switchDialog = !this.switchDialog;
  1081. },
  1082. onClose(val) {
  1083. this.switchDialog = val;
  1084. },
  1085. summaryMethod({ columns, data }) {
  1086. const sums = [];
  1087. if (columns.length > 0) {
  1088. columns.forEach((item, index) => {
  1089. sums[0] = "合计";
  1090. if (item.property == "orderQuantity" || item.property == "amount") {
  1091. let qtySum = 0;
  1092. let amountSum = 0;
  1093. data.forEach(e => {
  1094. qtySum = _.add(qtySum, Number(e.orderQuantity));
  1095. amountSum = _.add(amountSum, Number(e.amount));
  1096. });
  1097. //数量总计
  1098. if (item.property == "orderQuantity") {
  1099. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  1100. }
  1101. //金额总计
  1102. if (item.property == "amount") {
  1103. sums[index] = micrometerFormat(amountSum);
  1104. }
  1105. }
  1106. });
  1107. }
  1108. return sums;
  1109. },
  1110. getInvoice() {
  1111. if (!this.form.id) {
  1112. return this.$message.error("数据未提交,请提交数据");
  1113. }
  1114. for (let i = 0; i < this.goodsSelections.length; i++) {
  1115. if (!this.goodsSelections[i].id) {
  1116. return this.$message.error("明细表未提交数据,请提交数据");
  1117. }
  1118. }
  1119. if (this.$store.getters.outtaskStatus) {
  1120. this.$alert("出口发货单存在,请保存发货单再进行操作", "温馨提示", {
  1121. confirmButtonText: "确定",
  1122. type: "warning",
  1123. callback: action => {
  1124. console.log(action);
  1125. }
  1126. });
  1127. } else {
  1128. this.inInvoice();
  1129. }
  1130. },
  1131. inInvoice() {
  1132. const data = this.deepClone(this.form);
  1133. data.orderItemsList = this.deepClone(this.goodsSelections);
  1134. data.orderItemsList.forEach(e => {
  1135. e.actualQuantity = e.orderQuantity;
  1136. e.contractAmount = e.amount;
  1137. e.srcId = e.id;
  1138. e.packageRemarks = e.itemProp;
  1139. e.productDesc = e.itemDescription;
  1140. e.specificationAndModel = e.itemType;
  1141. delete e.id;
  1142. delete e.version;
  1143. delete e.status;
  1144. delete e.createUser;
  1145. delete e.createTime;
  1146. delete e.updateUser;
  1147. delete e.updateTime;
  1148. delete e.isDeleted;
  1149. });
  1150. delete data.id;
  1151. delete data.version;
  1152. delete data.status;
  1153. delete data.createUser;
  1154. delete data.createTime;
  1155. delete data.updateUser;
  1156. delete data.updateTime;
  1157. delete data.isDeleted;
  1158. delete data.orderStatus;
  1159. data.deliveryStatus = "录入";
  1160. data.srcOrderNo = data.sysNo;
  1161. delete data.sysNo;
  1162. data.corpName = data.corpsName;
  1163. delete data.corpsName;
  1164. this.$refs.crud.toggleSelection();
  1165. this.$router.$avueRouter.closeTag("/exportTrade/receipt/index");
  1166. this.$router.push({
  1167. path: "/exportTrade/receipt/index",
  1168. query: {
  1169. pageType: "Generate",
  1170. data: JSON.stringify(data)
  1171. }
  1172. });
  1173. },
  1174. //费用明细回调
  1175. beforeFinance(feesData, callback) {
  1176. this.advantageProjectData = feesData;
  1177. let params = {};
  1178. //暂时默认通过 之后优化
  1179. params.valid = true;
  1180. params.parentId = this.form.id;
  1181. params.srcOrderno = this.form.orderNo;
  1182. callback(params);
  1183. },
  1184. openEdit() {
  1185. const data = {
  1186. moduleName: "cg",
  1187. tableName: "business_order",
  1188. billId: this.form.id,
  1189. no: localStorage.getItem("browserID"),
  1190. billNo: this.form.orgOrderNo
  1191. };
  1192. this.inDetailsKey(this.$route.name, {
  1193. moduleName: "cg",
  1194. tableName: "business_order",
  1195. billId: this.form.id,
  1196. billNo: this.form.orgOrderNo
  1197. });
  1198. this.saveLoading = true;
  1199. this.checkLock(data).then(res => {
  1200. if (res.data.code == 200) {
  1201. this.onLock(data).then(res => {
  1202. if (res.data.code == 200) {
  1203. this.detailData.status = 2;
  1204. this.option = this.$options.data().option;
  1205. }
  1206. });
  1207. }
  1208. });
  1209. },
  1210. async saveColumn() {
  1211. const inSave = await this.saveColumnData(
  1212. this.getColumnName(3),
  1213. this.tableOption
  1214. );
  1215. if (inSave) {
  1216. this.$nextTick(() => {
  1217. this.$refs.crud.doLayout()
  1218. })
  1219. this.$message.success("保存成功");
  1220. //关闭窗口
  1221. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1222. }
  1223. },
  1224. async resetColumn() {
  1225. this.tableOption = tableOption;
  1226. const inSave = await this.delColumnData(
  1227. this.getColumnName(3),
  1228. tableOption
  1229. );
  1230. if (inSave) {
  1231. this.$nextTick(() => {
  1232. this.$refs.crud.doLayout()
  1233. })
  1234. this.$message.success("重置成功");
  1235. //关闭窗口
  1236. setTimeout(() => {
  1237. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1238. }, 1000);
  1239. }
  1240. },
  1241. async saveGoodsColumn() {
  1242. const inSave = await this.saveColumnData(
  1243. this.getColumnName(27),
  1244. this.goodsOption
  1245. );
  1246. if (inSave) {
  1247. this.$nextTick(() => {
  1248. this.$refs.goodsCrud.doLayout()
  1249. })
  1250. this.$message.success("保存成功");
  1251. //关闭窗口
  1252. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1253. }
  1254. },
  1255. async resetGoodsColumn() {
  1256. this.goodsOption = goodsOption;
  1257. const inSave = await this.delColumnData(
  1258. this.getColumnName(30),
  1259. goodsOption
  1260. );
  1261. if (inSave) {
  1262. this.$nextTick(() => {
  1263. this.$refs.goodsCrud.doLayout()
  1264. })
  1265. this.$message.success("重置成功");
  1266. //关闭窗口
  1267. setTimeout(() => {
  1268. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1269. }, 1000);
  1270. }
  1271. }
  1272. }
  1273. };
  1274. </script>
  1275. <style lang="scss" scoped>
  1276. .trading-form ::v-deep .el-form-item {
  1277. margin-bottom: 8px !important;
  1278. }
  1279. ::v-deep .el-form-item__error {
  1280. display: none !important;
  1281. }
  1282. ::v-deep .select-component {
  1283. display: flex !important;
  1284. }
  1285. </style>