detailsPage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <div class="borderless">
  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. <el-button type="success" class="copy-customer-btn" disabled>
  14. 复制新单
  15. </el-button>
  16. <el-button
  17. class="el-button--small-yh add-customer-btn"
  18. type="primary"
  19. :disabled="disabled"
  20. @click="editCustomer"
  21. >{{ form.id ? "确认修改" : "确认新增" }}
  22. </el-button>
  23. </div>
  24. <div style="margin-top: 60px;margin-bottom:35px">
  25. <containerTitle title="基础信息"></containerTitle>
  26. <basic-container>
  27. <avue-form ref="form" v-model="form" :option="option">
  28. <template slot="corpId">
  29. <select-component
  30. v-model="form.corpId"
  31. :configuration="configuration"
  32. :disabled="detailData.status == 1"
  33. ></select-component>
  34. </template>
  35. <template slot="exchangeRate">
  36. <el-input
  37. size="mini"
  38. v-model="form.exchangeRate"
  39. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  40. @change="rateChange"
  41. placeholder="请输入 汇率"
  42. :disabled="detailData.status == 1"
  43. ><template slot="append">%</template></el-input
  44. >
  45. </template>
  46. </avue-form>
  47. </basic-container>
  48. <div>
  49. <containerTitle title="商品信息"></containerTitle>
  50. <basic-container>
  51. <avue-crud
  52. ref="crud"
  53. :data="data"
  54. :option="tableOption"
  55. @row-del="rowDel"
  56. @selection-change="goodsSelectionChange"
  57. @saveColumn="saveColumn"
  58. >
  59. <template slot="price" slot-scope="{ row }">
  60. <el-input
  61. v-if="row.$cellEdit"
  62. v-model="row.price"
  63. size="small"
  64. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  65. @change="priceChange(row)"
  66. ></el-input>
  67. <span v-else>{{ row.price }}</span>
  68. </template>
  69. <template slot="orderQuantity" slot-scope="{ row }">
  70. <el-input
  71. v-if="row.$cellEdit"
  72. v-model="row.orderQuantity"
  73. size="small"
  74. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  75. @change="quantityChange(row)"
  76. ></el-input>
  77. <span v-else>{{ row.orderQuantity }}</span>
  78. </template>
  79. <template slot="itemType" slot-scope="{ row }">
  80. <el-select
  81. v-if="row.$cellEdit"
  82. v-model="row.itemType"
  83. filterable
  84. allow-create
  85. default-first-option
  86. placeholder="请输入"
  87. @focus="itemTypeFocus(row)"
  88. >
  89. <el-option
  90. v-for="(item, index) in itemtypeList"
  91. :key="index"
  92. :label="item.value"
  93. :value="item.value"
  94. >
  95. </el-option>
  96. </el-select>
  97. <span v-else>{{ row.itemType }}</span>
  98. </template>
  99. <template slot="menuLeft">
  100. <el-button
  101. type="primary"
  102. icon="el-icon-plus"
  103. size="small"
  104. @click.stop="newDetails"
  105. :disabled="detailData.status == 1"
  106. >新增明细</el-button
  107. >
  108. <el-button
  109. type="info"
  110. icon="el-icon-printer"
  111. size="small"
  112. @click.stop="openReport()"
  113. >报 表</el-button
  114. >
  115. </template>
  116. <template slot="menu" slot-scope="{ row, index }">
  117. <el-button
  118. size="small"
  119. icon="el-icon-edit"
  120. type="text"
  121. @click="rowCell(row, index)"
  122. :disabled="disabled"
  123. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  124. >
  125. <el-button
  126. size="small"
  127. icon="el-icon-edit"
  128. type="text"
  129. @click="rowDel(row, index)"
  130. :disabled="detailData.status == 1"
  131. >删 除</el-button
  132. >
  133. </template>
  134. </avue-crud>
  135. </basic-container>
  136. </div>
  137. <fee-info
  138. ref="feeInfo"
  139. :orderFeesList="orderFeesList"
  140. :disabled="detailData.status == 1"
  141. feeUrl="/trade-purchase/purchase-order/removeByFees"
  142. />
  143. <upload-file
  144. ref="uploadFile"
  145. title="合同附件"
  146. :orderFilesList="orderFilesList"
  147. :disabled="detailData.status == 1"
  148. delUrl="/trade-purchase/purchase-order/removeByFiles"
  149. />
  150. <div>
  151. <containerTitle title="银行信息"></containerTitle>
  152. <basic-container>
  153. <avue-form ref="form" v-model="form" :option="bankOption" />
  154. </basic-container>
  155. </div>
  156. </div>
  157. <el-dialog
  158. title="导入商品"
  159. append-to-body
  160. class="el-dialogDeep"
  161. :visible.sync="dialogVisible"
  162. width="60%"
  163. :close-on-click-modal="false"
  164. :destroy-on-close="true"
  165. :close-on-press-escape="false"
  166. @close="closeGoods"
  167. top="10vh"
  168. >
  169. <span>
  170. <el-row>
  171. <el-col :span="5">
  172. <div>
  173. <el-scrollbar>
  174. <basic-container style="margin-top:45px">
  175. <avue-tree :option="treeOption" @node-click="nodeClick" />
  176. </basic-container>
  177. </el-scrollbar>
  178. </div>
  179. </el-col>
  180. <el-col :span="19">
  181. <avue-crud
  182. :option="goodsOption"
  183. :table-loading="loading"
  184. :data="goodsList"
  185. ref="goodsCrud"
  186. @refresh-change="refreshChange"
  187. @selection-change="selectionChange"
  188. @row-click="rowClick"
  189. :page.sync="page"
  190. @on-load="onLoad"
  191. ></avue-crud>
  192. </el-col>
  193. </el-row>
  194. </span>
  195. <span slot="footer" class="dialog-footer">
  196. <el-button @click="dialogVisible = false">取 消</el-button>
  197. <el-button
  198. type="primary"
  199. @click="importGoods"
  200. :disabled="selectionList.length == 0"
  201. >导入</el-button
  202. >
  203. </span>
  204. </el-dialog>
  205. <report-dialog
  206. :switchDialog="switchDialog"
  207. :reportId="form.id"
  208. reportName="客户询价"
  209. @onClose="onClose()"
  210. ></report-dialog>
  211. </div>
  212. </template>
  213. <script>
  214. import tableOption from "./config/customerContact.json";
  215. import goodsOption from "./config/commodity.json";
  216. import feeInfo from "@/components/fee-info/main";
  217. import uploadFile from "@/components/upload-file/main";
  218. import {
  219. detail,
  220. submit,
  221. delItem,
  222. getDeptLazyTree,
  223. getGoods,
  224. getSysNo,
  225. getSpecification
  226. } from "@/api/exportTrade/purchaseContract";
  227. import _ from "lodash";
  228. import reportDialog from "@/components/report-dialog/main";
  229. import { isvalidatemobile, validatename } from "@/util/validate";
  230. export default {
  231. name: "detailsPageEdit",
  232. data() {
  233. const validatePhone = (rule, value, callback) => {
  234. if (value != "") {
  235. if (isvalidatemobile(value)[0]) {
  236. this.$message.error("手机号码格式不正确");
  237. callback(new Error(isvalidatemobile(value)[1]));
  238. } else {
  239. callback();
  240. }
  241. } else {
  242. callback();
  243. }
  244. };
  245. const validateName = (rule, value, callback) => {
  246. if (value != "") {
  247. if (validatename(value)) {
  248. this.$message.error("联系人格式不正确");
  249. callback(new Error(validatename(value)));
  250. } else {
  251. callback();
  252. }
  253. } else {
  254. callback();
  255. }
  256. };
  257. return {
  258. configuration: {
  259. multipleChoices: false,
  260. multiple: false,
  261. collapseTags: false,
  262. placeholder: "请点击右边按钮选择",
  263. dicData: []
  264. },
  265. switchDialog: false,
  266. form: {},
  267. disabled: false,
  268. dialogVisible: false,
  269. tableOption: tableOption,
  270. option: {
  271. menuBtn: false,
  272. labelWidth: 100,
  273. column: [
  274. {
  275. label: "客户名称",
  276. prop: "corpId",
  277. rules: [
  278. {
  279. required: true,
  280. message: "",
  281. trigger: "blur"
  282. }
  283. ],
  284. span: 8,
  285. slot: true
  286. },
  287. {
  288. label: "系统号",
  289. prop: "sysNo",
  290. span: 8,
  291. disabled: true
  292. },
  293. {
  294. label: "订单状态",
  295. prop: "orderStatus",
  296. span: 8,
  297. type: "select",
  298. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  299. props: {
  300. label: "dictValue",
  301. value: "dictValue"
  302. }
  303. },
  304. {
  305. label: "订单号",
  306. prop: "orderNo",
  307. span: 8
  308. },
  309. {
  310. label: "联系人",
  311. prop: "corpAttn",
  312. span: 8,
  313. rules: [{ validator: validateName, trigger: "blur" }]
  314. },
  315. {
  316. label: "电话",
  317. prop: "corpTel",
  318. span: 8,
  319. rules: [{ validator: validatePhone, trigger: "blur" }]
  320. },
  321. {
  322. label: "采购日期",
  323. prop: "businesDate",
  324. span: 8,
  325. type: "date",
  326. format: "yyyy-MM-dd",
  327. valueFormat: "yyyy-MM-dd 00:00:00"
  328. },
  329. {
  330. label: "预计交货日期",
  331. prop: "plannedDeliveryDate",
  332. span: 8,
  333. type: "date",
  334. format: "yyyy-MM-dd",
  335. valueFormat: "yyyy-MM-dd 00:00:00"
  336. },
  337. {
  338. label: "实际交货日",
  339. prop: "requiredDeliveryDate",
  340. span: 8,
  341. type: "date",
  342. format: "yyyy-MM-dd",
  343. valueFormat: "yyyy-MM-dd 00:00:00"
  344. },
  345. {
  346. label: "是否开票",
  347. prop: "ifInvoice",
  348. span: 8,
  349. type: "select",
  350. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  351. props: {
  352. label: "dictValue",
  353. value: "dictValue"
  354. }
  355. },
  356. {
  357. label: "收款方式",
  358. prop: "paymentType",
  359. span: 8,
  360. type: "select",
  361. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  362. props: {
  363. label: "dictValue",
  364. value: "dictValue"
  365. }
  366. },
  367. {
  368. label: "收款说明",
  369. prop: "paymentTypeDescription",
  370. span: 8
  371. },
  372. {
  373. label: "币别",
  374. prop: "currency",
  375. span: 8,
  376. type: "select",
  377. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  378. props: {
  379. label: "dictValue",
  380. value: "dictValue"
  381. }
  382. },
  383. {
  384. label: "汇率",
  385. prop: "exchangeRate",
  386. span: 8,
  387. slot: true
  388. },
  389. {
  390. label: "备注",
  391. prop: "orderRemark",
  392. type: "textarea",
  393. minRows: 2,
  394. span: 8
  395. }
  396. ]
  397. },
  398. treeOption: {
  399. nodeKey: "id",
  400. lazy: true,
  401. treeLoad: function(node, resolve) {
  402. const parentId = node.level === 0 ? 0 : node.data.id;
  403. getDeptLazyTree(parentId).then(res => {
  404. resolve(
  405. res.data.data.map(item => {
  406. return {
  407. ...item,
  408. leaf: !item.hasChildren
  409. };
  410. })
  411. );
  412. });
  413. },
  414. addBtn: false,
  415. menu: false,
  416. size: "small",
  417. props: {
  418. label: "title",
  419. value: "value",
  420. children: "children"
  421. }
  422. },
  423. bankOption: {
  424. menuBtn: false,
  425. labelWidth: 100,
  426. column: [
  427. {
  428. label: "银行",
  429. prop: "banks",
  430. span: 8
  431. },
  432. {
  433. label: "银行信息",
  434. prop: "banksAccountName",
  435. span: 16,
  436. type: "textarea",
  437. minRows: 2
  438. }
  439. ]
  440. },
  441. insuranceOption: {
  442. menuBtn: false,
  443. labelWidth: 100,
  444. column: [
  445. {
  446. label: "保险描述",
  447. prop: "insuranceRemarks",
  448. span: 24,
  449. type: "textarea",
  450. minRows: 2
  451. }
  452. ]
  453. },
  454. markOption: {
  455. menuBtn: false,
  456. labelWidth: 100,
  457. column: [
  458. {
  459. label: "唛头描述",
  460. prop: "marks",
  461. span: 24,
  462. type: "textarea",
  463. minRows: 2
  464. }
  465. ]
  466. },
  467. page: {
  468. pageSize: 10,
  469. currentPage: 1,
  470. total: 0
  471. },
  472. loading: false,
  473. goodsOption: goodsOption,
  474. data: [],
  475. goodsList: [],
  476. selectionList: [],
  477. treeDeptId: null,
  478. orderFeesList: [],
  479. orderFilesList: [],
  480. orderItemIds: [],
  481. itemtypeList: []
  482. };
  483. },
  484. props: {
  485. detailData: {
  486. type: Object
  487. }
  488. },
  489. components: {
  490. reportDialog,
  491. feeInfo,
  492. uploadFile
  493. },
  494. async created() {
  495. this.tableOption = await this.getColumnData(
  496. this.getColumnName(3),
  497. tableOption
  498. );
  499. if (this.detailData.id) {
  500. this.getDetail(this.detailData.id);
  501. }
  502. if (this.detailData.status == 1) {
  503. this.option.disabled = true;
  504. this.bankOption.disabled = true;
  505. this.insuranceOption.disabled = true;
  506. this.markOption.disabled = true;
  507. }
  508. let _this = this;
  509. this.tableOption.column.forEach(e => {
  510. if (e.prop == "taxRate") {
  511. e.formatter = function(row) {
  512. return _this.textFormat(
  513. Number(row.taxRate ? row.taxRate : 0) / 100,
  514. "0.00%"
  515. );
  516. };
  517. }
  518. if (e.prop == "amount" || e.prop == "price") {
  519. e.formatter = function(row) {
  520. return _this.textFormat(
  521. Number(row.amount ? row.amount : 0),
  522. "#,##0.00"
  523. );
  524. };
  525. }
  526. });
  527. if (this.detailData.pageType == "new") {
  528. getSysNo().then(res => {
  529. this.form.sysNo = res.data.data;
  530. });
  531. }
  532. },
  533. methods: {
  534. rowCell(row, index) {
  535. if (row.$cellEdit == true) {
  536. this.$set(row, "$cellEdit", false);
  537. } else {
  538. this.$set(row, "$cellEdit", true);
  539. }
  540. },
  541. itemTypeFocus(row) {
  542. this.itemtypeList = [];
  543. getSpecification({ goodId: row.itemId }).then(res => {
  544. const data = res.data.data;
  545. this.itemtypeList = data.map(item => ({ value: item }));
  546. });
  547. },
  548. priceChange(row) {
  549. console.log(row);
  550. if (!row.price) {
  551. row.price = 0;
  552. } else {
  553. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  554. }
  555. },
  556. quantityChange(row) {
  557. if (!row.orderQuantity) {
  558. row.orderQuantity = 0;
  559. } else {
  560. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  561. }
  562. },
  563. rateChange(row) {
  564. console.log(row);
  565. if (row >= 100) {
  566. this.form.exchangeRate = 0;
  567. this.$message.error("汇率不能超过100%");
  568. }
  569. },
  570. rowSave(row) {
  571. console.log(row);
  572. this.$set(row, "$cellEdit", false);
  573. },
  574. rowDel(row, index) {
  575. this.$confirm("确定删除数据?", {
  576. confirmButtonText: "确定",
  577. cancelButtonText: "取消",
  578. type: "warning"
  579. }).then(() => {
  580. if (row.id) {
  581. delItem(row.id).then(res => {
  582. this.$message({
  583. type: "success",
  584. message: "删除成功!"
  585. });
  586. this.data.splice(index, 1);
  587. });
  588. } else {
  589. this.$message({
  590. type: "success",
  591. message: "删除成功!"
  592. });
  593. this.data.splice(index, 1);
  594. }
  595. });
  596. },
  597. importGoods() {
  598. this.selectionList.forEach(e => {
  599. this.data.push({
  600. itemId: e.id,
  601. code: e.code,
  602. cname: e.cname,
  603. priceCategory: e.goodsTypeName,
  604. itemUrl: e.url,
  605. itemProp: null,
  606. itemDescription: null,
  607. itemType: null,
  608. orderQuantity: 0,
  609. tradeTerms: null,
  610. price: 0,
  611. amount: 0,
  612. taxRate: 0,
  613. unit: e.unit,
  614. remarks: null,
  615. $cellEdit: true
  616. });
  617. });
  618. this.dialogVisible = false;
  619. },
  620. closeGoods() {
  621. this.selectionList = [];
  622. this.treeDeptId = "";
  623. },
  624. goodsSelectionChange(list) {
  625. this.orderItemIds = [];
  626. list.map(e => {
  627. this.orderItemIds.push(e.id);
  628. });
  629. console.log(this.orderItemIds);
  630. },
  631. selectionChange(list) {
  632. this.selectionList = list;
  633. },
  634. rowClick(row) {
  635. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  636. },
  637. nodeClick(data) {
  638. this.treeDeptId = data.id;
  639. this.page.currentPage = 1;
  640. this.onLoad(this.page);
  641. },
  642. //费用查询
  643. onLoad(page, params = {}) {
  644. this.loading = true;
  645. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  646. const data = res.data.data;
  647. this.page.total = data.total;
  648. this.goodsList = data.records;
  649. this.loading = false;
  650. if (this.page.total) {
  651. this.goodsOption.height = window.innerHeight - 550;
  652. } else {
  653. this.goodsOption.height = window.innerHeight - 475;
  654. }
  655. });
  656. },
  657. //商品明细导入
  658. newDetails() {
  659. this.dialogVisible = !this.dialogVisible;
  660. },
  661. getDetail(id) {
  662. detail(id).then(res => {
  663. this.form = res.data.data;
  664. this.data = res.data.data.itemsVOList ? res.data.data.itemsVOList : [];
  665. this.orderFeesList = res.data.data.orderFeesList
  666. ? res.data.data.orderFeesList
  667. : [];
  668. this.orderFilesList = res.data.data.orderFilesList
  669. ? res.data.data.orderFilesList
  670. : [];
  671. this.configuration.dicData = this.form.corpsName;
  672. });
  673. },
  674. //修改提交触发
  675. editCustomer() {
  676. this.$refs["form"].validate((valid, done) => {
  677. done();
  678. if (valid) {
  679. const orderFeesList = this.$refs.feeInfo.submitData();
  680. for (let i = 0; i < orderFeesList.length; i++) {
  681. if (orderFeesList[i].corpId == null) {
  682. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  683. }
  684. if (orderFeesList[i].price == 0) {
  685. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  686. }
  687. if (orderFeesList[i].quantity == 0) {
  688. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  689. }
  690. }
  691. const orderFilesList = this.$refs.uploadFile.submitData();
  692. submit({
  693. ...this.form,
  694. itemsVOList: this.data,
  695. orderFeesList: orderFeesList,
  696. orderFilesList: orderFilesList,
  697. tradeType: "CK",
  698. billType: "CG"
  699. }).then(res => {
  700. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  701. this.form.id = res.data.data;
  702. });
  703. } else {
  704. return false;
  705. }
  706. });
  707. },
  708. //返回列表
  709. backToList() {
  710. this.$emit("goBack");
  711. },
  712. openReport() {
  713. this.switchDialog = !this.switchDialog;
  714. },
  715. onClose(val) {
  716. this.switchDialog = val;
  717. },
  718. async saveColumn() {
  719. const inSave = await this.saveColumnData(
  720. this.getColumnName(3),
  721. this.tableOption
  722. );
  723. if (inSave) {
  724. this.$message.success("保存成功");
  725. //关闭窗口
  726. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  727. }
  728. }
  729. }
  730. };
  731. </script>
  732. <style lang="scss" scoped>
  733. .customer-head {
  734. position: fixed;
  735. top: 105px;
  736. width: 100%;
  737. margin-left: -10px;
  738. height: 62px;
  739. background: #ffffff;
  740. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  741. z-index: 999;
  742. }
  743. .customer-back {
  744. cursor: pointer;
  745. line-height: 62px;
  746. font-size: 16px;
  747. color: #323233;
  748. font-weight: 400;
  749. }
  750. .back-icon {
  751. line-height: 64px;
  752. font-size: 20px;
  753. margin-right: 8px;
  754. }
  755. .copy-customer-btn {
  756. position: fixed;
  757. right: 140px;
  758. top: 115px;
  759. }
  760. .add-customer-btn {
  761. position: fixed;
  762. right: 36px;
  763. top: 115px;
  764. }
  765. ::v-deep .el-form-item {
  766. margin-bottom: 8px;
  767. }
  768. ::v-deep .el-form-item__error {
  769. display: none;
  770. }
  771. ::v-deep .select-component {
  772. display: flex;
  773. }
  774. </style>