detailsPage.vue 21 KB

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