detail.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  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. :loading="btnLoading"
  11. >返回列表</el-button>
  12. </div>
  13. <div class="add-customer-btn">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. class="el-button--small-yh"
  18. @click.stop="openEdit"
  19. v-if="form.id && disabled"
  20. >编 辑</el-button>
  21. <el-button
  22. type="primary"
  23. size="small"
  24. class="el-button--small-yh"
  25. style="margin-right: 8px;"
  26. @click="dealerSubmit"
  27. :disabled="disabled"
  28. v-if="form.id"
  29. >
  30. {{ form.status == 0? '确认订单': form.status == 3? '撤销订单': '' }}
  31. </el-button>
  32. <el-dropdown style="margin-right: 8px;">
  33. <el-button type="warning" size="small">账单处理<i class="el-icon-arrow-down el-icon--right"></i></el-button>
  34. <el-dropdown-menu slot="dropdown">
  35. <el-dropdown-item
  36. @click.native="applySettlement('申请')"
  37. :disabled="disabled">申请货款
  38. </el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. <el-button
  42. type="success"
  43. :disabled="!form.id"
  44. size="small"
  45. @click="copyDoc"
  46. :loading="btnLoading"
  47. >
  48. 复制单据
  49. </el-button>
  50. <el-button
  51. type="primary"
  52. @click="editCustomer"
  53. size="small"
  54. :loading="btnLoading"
  55. :disabled="disabled || confirmDisabled"
  56. >保存数据
  57. </el-button>
  58. </div>
  59. </div>
  60. <div class="customer-main">
  61. <containerTitle title="基础信息"/>
  62. <basic-container :showBtn="true">
  63. <avue-form
  64. ref="form"
  65. class="trading-form"
  66. v-model="form"
  67. :option="option"
  68. >
  69. <template slot="corpId">
  70. <crop-select
  71. v-model="form.corpId"
  72. @getCorpData="getCorpData"
  73. corpType="GYS"
  74. :disabled="disabled || confirmDisabled"
  75. ></crop-select>
  76. </template>
  77. <template slot="storageId">
  78. <warehouse-select
  79. v-model="form.storageId"
  80. :configuration="configurationWarehouse"
  81. :disabled="disabled || confirmDisabled"/>
  82. </template>
  83. </avue-form>
  84. </basic-container>
  85. <containerTitle title="商品信息"/>
  86. <basic-container>
  87. <avue-crud
  88. ref="crud"
  89. :data="dataList"
  90. :option="tableOption"
  91. :cell-style="cellStyle"
  92. @saveColumn="saveColumn"
  93. @resetColumn="resetColumn"
  94. >
  95. <template slot="menuLeft">
  96. <el-button
  97. type="primary"
  98. icon="el-icon-plus"
  99. size="small"
  100. @click.stop="newDetails"
  101. :disabled="disabled || confirmDisabled"
  102. >录入明细</el-button>
  103. <el-button
  104. type="info"
  105. icon="el-icon-printer"
  106. size="small"
  107. @click.stop="openReport()"
  108. >报 表</el-button
  109. >
  110. </template>
  111. <template slot="menu" slot-scope="{ row, index }">
  112. <el-button
  113. size="small"
  114. icon="el-icon-edit"
  115. type="text"
  116. @click="rowCell(row, index)"
  117. :disabled="disabled || confirmDisabled"
  118. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  119. >
  120. <el-button
  121. size="small"
  122. icon="el-icon-delete"
  123. type="text"
  124. @click="rowDel(row, index)"
  125. :disabled="disabled || confirmDisabled"
  126. >删除</el-button
  127. >
  128. </template>
  129. <template slot="cname" slot-scope="{ row, index }">
  130. <span v-if="row.$cellEdit" style="display:flex">
  131. <el-select
  132. v-model="row.itemId"
  133. placeholder="请选择"
  134. size="small"
  135. style="width:60%"
  136. @change="cnameChange(row, index)"
  137. :disabled="!form.lotNo"
  138. >
  139. <el-option
  140. v-for="item in goodsoptions"
  141. :key="item.id"
  142. :label="item.cname"
  143. :value="item.id"
  144. >
  145. </el-option>
  146. </el-select>
  147. <el-button
  148. icon="el-icon-search"
  149. size="small"
  150. @click="rePick(row, index)"
  151. ></el-button>
  152. </span>
  153. <span v-else> {{ row.cname }}</span>
  154. </template>
  155. <template slot="batch" slot-scope="{row, index}">
  156. <span>{{ row.batch == 0? '否': '是' }}</span>
  157. </template>
  158. <template slot="orderQuantity" slot-scope="{ row, index }">
  159. <el-input-number
  160. v-if="row.$cellEdit"
  161. v-model="row.orderQuantity"
  162. size="small"
  163. :controls="false"
  164. :precision="0"
  165. @input="amountChange(row)"
  166. style="width: 100%"
  167. :disabled="!form.lotNo"
  168. />
  169. <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
  170. </template>
  171. <template slot="price" slot-scope="{ row, index }">
  172. <el-input-number
  173. v-if="row.$cellEdit"
  174. v-model="row.price"
  175. size="small"
  176. :controls="false"
  177. :precision="2"
  178. @input="amountChange(row)"
  179. style="width: 100%"
  180. :disabled="!form.lotNo"
  181. ></el-input-number>
  182. <span v-else>{{ row.price }}</span>
  183. </template>
  184. <!-- 单位-->
  185. <template slot="unit" slot-scope="{ row, index }">
  186. <el-select
  187. v-if="row.$cellEdit"
  188. v-model="row.unit"
  189. size="small"
  190. :disabled="!form.lotNo"
  191. clearable
  192. filterable
  193. >
  194. <el-option
  195. v-for="(item, index) in unitOption"
  196. :key="index"
  197. :label="item.dictValue"
  198. :value="item.dictValue"
  199. />
  200. </el-select>
  201. <span v-else>{{ row.unit }}</span>
  202. </template>
  203. <template slot="amount" slot-scope="{ row, index }">
  204. <span>{{ row.amount | decimalFormat }}</span>
  205. </template>
  206. <template slot="storageQuantity" slot-scope="{ row, index }">
  207. <span>{{ row.storageQuantity | IntegerFormat }}</span>
  208. </template>
  209. </avue-crud>
  210. </basic-container>
  211. <containerTitle title="详细信息"/>
  212. <basic-container :showBtn="true">
  213. <avue-form
  214. ref="form1"
  215. class="trading-form"
  216. v-model="form"
  217. :option="detailOption"
  218. ></avue-form>
  219. </basic-container>
  220. <containerTitle title="附件管理"></containerTitle>
  221. <c-upload
  222. :data="uploadData"
  223. deleteUrl="/api/blade-client/corpsbank/update"
  224. :enumerationValue="84"
  225. :disabled="disabled || confirmDisabled"
  226. />
  227. </div>
  228. <el-dialog
  229. title="导入商品"
  230. append-to-body
  231. class="el-dialogDeep"
  232. :visible.sync="dialogVisible"
  233. width="80%"
  234. :close-on-click-modal="false"
  235. :destroy-on-close="true"
  236. :close-on-press-escape="false"
  237. @close="closeGoods"
  238. top="5vh"
  239. v-dialog-drag
  240. >
  241. <span>
  242. <el-row>
  243. <el-col :span="4">
  244. <div>
  245. <el-scrollbar>
  246. <basic-container>
  247. <avue-tree
  248. :option="treeOption"
  249. @node-click="nodeClick"
  250. :style="treeStyle"
  251. />
  252. </basic-container>
  253. </el-scrollbar>
  254. </div>
  255. </el-col>
  256. <el-col :span="20">
  257. <avue-crud
  258. :option="goodsOption"
  259. :table-loading="loading"
  260. :data="goodsList"
  261. ref="goodsCrud"
  262. :search.sync="search"
  263. @search-change="searchChange"
  264. @selection-change="selectionChange"
  265. @row-click="rowClick"
  266. :page.sync="page"
  267. @on-load="onLoad"
  268. @saveColumn="saveGoodsColumn"
  269. @resetColumn="resetGoodsColumn"
  270. :cell-style="cellStyle"
  271. >
  272. <template slot="menuLeft">
  273. <el-tabs v-model="activeName" @tab-click="tabHandle">
  274. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  275. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  276. </el-tabs>
  277. </template>
  278. <template slot-scope="scope" slot="menu">
  279. <el-button
  280. type="text"
  281. icon="el-icon-edit"
  282. size="small"
  283. @click.stop="importStagList(scope.row,scope.index)"
  284. v-if="activeName=='searchList'"
  285. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
  286. >选择
  287. </el-button>
  288. <el-button
  289. type="text"
  290. icon="el-icon-delete"
  291. size="small"
  292. @click.stop="removeStagList(scope.row,scope.index)"
  293. v-else
  294. >移除
  295. </el-button>
  296. </template>
  297. </avue-crud>
  298. </el-col>
  299. </el-row>
  300. </span>
  301. <span slot="footer" class="dialog-footer">
  302. <el-button @click="dialogVisible = false">取 消</el-button>
  303. <el-button
  304. type="primary"
  305. @click="importGoods"
  306. :disabled="selectionList.length == 0 && goodsListSave.length == 0"
  307. >导入</el-button
  308. >
  309. </span>
  310. </el-dialog>
  311. <!-- 账单-->
  312. <el-dialog
  313. append-to-body
  314. title="账单"
  315. class="el-dialogDeep"
  316. :visible.sync="financialAccountDialog"
  317. width="70%"
  318. :close-on-click-modal="false"
  319. :destroy-on-close="true"
  320. :close-on-press-escape="false"
  321. v-dialog-drag
  322. >
  323. <financial-account
  324. :billType="billType"
  325. :billData="{}"
  326. :arrList="applyPaymentList"
  327. :belongCompany="form.belongToCorpId"
  328. @choceFun="choceFun"
  329. />
  330. </el-dialog>
  331. </div>
  332. </template>
  333. <script>
  334. import tableOption from "./config/customerContact.json";
  335. import goodsOption from "./config/commodity.json";
  336. import {getDeptLazyTree,
  337. getGoods,} from "@/api/basicData/customerInquiry";
  338. import {selectGoodsNum} from "@/api/basicData/inventoryAccount"; // 库存查询
  339. import {getUserInfo} from "@/api/system/user"; //登录用户信息
  340. import {dataDetail, removeGoods, typeSave, dealerSubmit} from "@/api/dealer/purchase";
  341. import {
  342. isDiscount,
  343. isPercentage,
  344. micrometerFormat,
  345. IntegerFormat
  346. } from "@/util/validate";
  347. import reportDialog from "@/components/report-dialog/main";
  348. import financialAccount from "../../../components/finance/financialAccount";
  349. import checkSchedule from "@/components/check/checkSchedule";
  350. import billApplication from "@/components/bill/billApplication";
  351. import { customerList as feeList } from "@/api/basicData/basicFeesDesc";
  352. import {getDetail} from "@/api/basicData/inventoryAccount";
  353. export default {
  354. name: "detail",
  355. props: {
  356. detailData: {
  357. type: Object
  358. }
  359. },
  360. components: {
  361. reportDialog,
  362. billApplication,
  363. financialAccount,
  364. checkSchedule,
  365. },
  366. data() {
  367. return {
  368. pageLoading: false,
  369. btnLoading: false,
  370. disabled: false,
  371. confirmDisabled: false, // 确认禁用
  372. form: {},
  373. option: {
  374. menuBtn: false,
  375. labelWidth: 100,
  376. column: [
  377. {
  378. label: "供应商",
  379. prop: "corpId",
  380. rules: [
  381. {
  382. required: true,
  383. message: " ",
  384. trigger: "change"
  385. }
  386. ],
  387. span: 16,
  388. slot: true,
  389. },
  390. {
  391. label: "业务时间",
  392. prop: "businesDate",
  393. span: 8,
  394. type: "date",
  395. format: "yyyy-MM-dd",
  396. valueFormat: "yyyy-MM-dd 00:00:00",
  397. rules: [
  398. {
  399. required: true,
  400. message: "",
  401. trigger: "blur"
  402. }
  403. ]
  404. },
  405. {
  406. label: "批次号",
  407. prop: "lotNo",
  408. rules: [
  409. {
  410. required: true,
  411. message: " ",
  412. trigger: "blur"
  413. }
  414. ],
  415. span: 8,
  416. slot: true
  417. },
  418. {
  419. label: "收货仓库",
  420. prop: "storageId",
  421. span: 8,
  422. rules: [
  423. {
  424. required: true,
  425. message: " ",
  426. trigger: "change"
  427. }
  428. ],
  429. },
  430. {
  431. label: "电话",
  432. prop: "corpTel",
  433. span: 8
  434. },
  435. {
  436. label: "地址",
  437. prop: "arrivalAddress",
  438. span: 8
  439. },
  440. {
  441. label: "备注",
  442. prop: "orderRemark",
  443. type: "textarea",
  444. minRows: 2,
  445. span: 24
  446. },
  447. ],
  448. },
  449. detailOption: {
  450. menuBtn: false,
  451. labelWidth: 100,
  452. column: [
  453. {
  454. label: "系统号",
  455. prop: "sysNo",
  456. span: 8,
  457. disabled: true
  458. },
  459. {
  460. label: "打印时间",
  461. prop: "printTime",
  462. span: 8,
  463. disabled: true
  464. },
  465. {
  466. label: "打印次数",
  467. prop: "printNumber",
  468. span: 8,
  469. disabled: true
  470. },
  471. {
  472. label: "客户欠款",
  473. prop: "corpDebt",
  474. span: 8,
  475. disabled: true
  476. },
  477. {
  478. label: "总数量",
  479. prop: "orderQuantity",
  480. span: 8,
  481. disabled: true
  482. },
  483. {
  484. label: "应付金额",
  485. prop: "debitAmount",
  486. span: 8,
  487. disabled: true
  488. },
  489. {
  490. label: "总金额",
  491. prop: "amount",
  492. span: 8,
  493. disabled: true
  494. },
  495. {
  496. label: "制单人",
  497. prop: "createUserName",
  498. span: 8,
  499. disabled: true,
  500. },
  501. ]
  502. },
  503. // 仓库配置
  504. configurationWarehouse: {
  505. multipleChoices: false,
  506. multiple: false,
  507. collapseTags: false,
  508. placeholder: "请点击右边按钮选择",
  509. dicData: [],
  510. },
  511. dataList: [],
  512. tableOption: {},
  513. dialogVisible: false,
  514. selectionList: [],
  515. treeDeptId: null,
  516. reData: null,
  517. treeOption: {
  518. nodeKey: "id",
  519. lazy: true,
  520. treeLoad: function(node, resolve) {
  521. const parentId = node.level === 0 ? 0 : node.data.id;
  522. getDeptLazyTree(parentId).then(res => {
  523. resolve(
  524. res.data.data.map(item => {
  525. return {
  526. ...item,
  527. leaf: !item.hasChildren
  528. };
  529. })
  530. );
  531. });
  532. },
  533. addBtn: false,
  534. menu: false,
  535. size: "small",
  536. props: {
  537. label: "title",
  538. value: "value",
  539. children: "children"
  540. }
  541. },
  542. page: {
  543. pageSize: 10,
  544. currentPage: 1,
  545. total: 0
  546. },
  547. search: {},
  548. goodsList: [],
  549. loading: false,
  550. goodsOption: {},
  551. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  552. goodsoptions: [],
  553. uploadData: [],
  554. activeName: 'searchList',
  555. // 商品列表数据合计
  556. goodsListShow: [],
  557. // 商品列表暂存
  558. goodsListSave: [],
  559. pageList: {
  560. pageSize: 10,
  561. currentPage: 1,
  562. total: 0
  563. },
  564. applyPaymentList: [],
  565. billType:"收费", //账单类型
  566. billData:{}, //账单需要数据
  567. applySettlementDialog:false,//生成账单组件
  568. financialAccountDialog:false,
  569. feesOption: [],
  570. unitOption: [],
  571. }
  572. },
  573. async created() {
  574. this.tableOption = await this.getColumnData(
  575. this.getColumnName(82),
  576. tableOption
  577. );
  578. this.goodsOption = await this.getColumnData(
  579. this.getColumnName(83),
  580. goodsOption
  581. );
  582. this.getWorkDicts('unit').then(res => {
  583. this.unitOption = res.data.data;
  584. })
  585. getGoods(1, 500).then(res => {
  586. this.goodsoptions = res.data.data.records;
  587. });
  588. getUserInfo().then(res => {
  589. this.$set(this.form, 'createUserName', res.data.data.realName)
  590. this.$set(this.form, 'createUser', res.data.data.id)
  591. })
  592. feeList().then(res => {
  593. this.feesOption = res.data.data.records
  594. });
  595. this.$set(this.form, 'status', 0);
  596. if (this.detailData.query) {
  597. this.disabled = true;
  598. this.option.column.map(e => {
  599. this.$set(e, 'disabled', true)
  600. })
  601. this.queryData(this.detailData.id);
  602. } else {
  603. this.dataList = [
  604. {
  605. code: null,
  606. cname: null,
  607. typeno: null,
  608. brandItem: null,
  609. specsOne: null,
  610. specsTwo: null,
  611. unit: null,
  612. storageQuantity: 0,
  613. orderQuantity: 0,
  614. size: null,
  615. price: 0,
  616. amount: 0,
  617. $cellEdit: true
  618. }
  619. ]
  620. }
  621. },
  622. filters: {
  623. IntegerFormat(num) {
  624. return IntegerFormat(num);
  625. },
  626. decimalFormat(num) {
  627. return num ? Number(num).toFixed(2) : "0.00";
  628. }
  629. },
  630. methods: {
  631. // 查询
  632. queryData(id) {
  633. this.pageLoading = true;
  634. dataDetail(id).then(res => {
  635. this.form = res.data.data;
  636. this.form.amount = Number(this.form.amount).toFixed(2);
  637. this.confirmDisabled = this.form.status == 3? true: false;
  638. if (this.confirmDisabled) {
  639. this.option.column.map(e => {
  640. this.$set(e, 'disabled', true)
  641. })
  642. }
  643. this.dataList = this.form.orderItemsList? this.form.orderItemsList: [];
  644. this.uploadData = this.form.orderFilesList? this.form.orderFilesList: [];
  645. delete this.form.orderItemsList;
  646. delete this.form.orderFilesList;
  647. }).finally(() => {
  648. this.pageLoading = false;
  649. })
  650. },
  651. cellStyle() {
  652. return "padding:0;height:40px;";
  653. },
  654. openEdit() {
  655. this.disabled = false;
  656. if (this.form.status != 3) {
  657. this.option.column.map(e => {
  658. this.$set(e, 'disabled', false)
  659. })
  660. }
  661. },
  662. copyDoc() {
  663. this.$emit("copyOrder", this.form.id);
  664. },
  665. getCorpData(row) {},
  666. //修改提交触发
  667. editCustomer(status) {
  668. this.$refs["form"].validate((valid, done) => {
  669. done();
  670. if (valid) {
  671. // 总金额计算
  672. let amount = 0;
  673. this.dataList.forEach(item => {
  674. amount = Number(amount) + Number(item.amount)
  675. })
  676. this.$set(this.form, 'debitAmount', amount.toFixed(2));
  677. this.$set(this.form, 'amount', amount.toFixed(2));
  678. this.form.billType = 'CG';
  679. this.$set(this.form, 'itemsVOList', this.dataList);
  680. this.$set(this.form, 'orderFilesList', this.uploadData);
  681. this.btnLoading = true;
  682. typeSave(this.form).then(res => {
  683. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  684. this.queryData(res.data.data);
  685. }).finally(() => {
  686. this.btnLoading = false;
  687. })
  688. }
  689. })
  690. },
  691. //返回列表
  692. backToList() {
  693. this.$emit("goBack");
  694. },
  695. async saveColumn() {
  696. const inSave = await this.saveColumnData(
  697. this.getColumnName(82),
  698. this.tableOption
  699. );
  700. if (inSave) {
  701. this.$message.success("保存成功");
  702. //关闭窗口
  703. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  704. this.$nextTick(() => {
  705. this.$refs.crud.doLayout()
  706. })
  707. }
  708. },
  709. async resetColumn() {
  710. this.tableOption = tableOption;
  711. const inSave = await this.delColumnData(
  712. this.getColumnName(82),
  713. tableOption
  714. );
  715. if (inSave) {
  716. this.$nextTick(() => {
  717. this.$refs.crud.doLayout()
  718. })
  719. this.$message.success("重置成功");
  720. //关闭窗口
  721. setTimeout(() => {
  722. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  723. }, 1000);
  724. }
  725. },
  726. //商品明细导入
  727. newDetails() {
  728. this.$refs["form"].validate((valid) => {
  729. if (valid) {
  730. this.dialogVisible = !this.dialogVisible;
  731. }
  732. })
  733. // if (!this.form.corpId) {
  734. // return this.$message.error("请选择客户名称");
  735. // }
  736. },
  737. importGoods() {
  738. let form = {};
  739. if (this.reData) {
  740. if (this.selectionList.length != 1) {
  741. return this.$message.error("重新选择的时候只能选择一条数据");
  742. } else {
  743. this.selectionList.forEach(e => {
  744. this.dataList.forEach(async (item, index) => {
  745. if (index == this.reData.index) {
  746. form = await this.getStockInfo({
  747. tradeType: 'JXS',
  748. goodsId: e.id,
  749. storageId: this.form.storageId,
  750. lotNo: e.batch == 1? this.form.lotNo: null
  751. })
  752. item.storageQuantity = form.stock;
  753. item.purchaseAmount = form.purchaseAmount;
  754. item.itemId = e.id;
  755. item.code = e.code;
  756. item.cname = e.cname;
  757. item.corpId = e.corpId;
  758. item.corpName = e.corpName;
  759. item.brandItem = e.brandItem;
  760. item.specsOne = e.specsOne;
  761. item.specsTwo = e.specsTwo;
  762. item.typeno = e.typeno;
  763. item.unit = e.unit;
  764. item.size = e.size;
  765. item.lotNo = e.batch == 1? this.form.lotNo: null;
  766. item.priceCategory = e.goodsTypeName;
  767. item.$cellEdit = true;
  768. }
  769. });
  770. });
  771. }
  772. } else {
  773. if (this.goodsListSave.length > 0) { // 暂存的有数据
  774. this.goodsListSave.forEach(async e => {
  775. form = await this.getStockInfo({
  776. tradeType: 'JXS',
  777. goodsId: e.id,
  778. storageId: this.form.storageId,
  779. lotNo: e.batch == 1? this.form.lotNo: null
  780. })
  781. e.storageQuantity = form.stock;
  782. e.purchaseAmount = form.purchaseAmount;
  783. this.dataList.push({
  784. itemId: e.id,
  785. code: e.code,
  786. cname: e.cname,
  787. brandItem: e.brandItem,
  788. specsOne: e.specsOne,
  789. specsTwo: e.specsTwo,
  790. typeno: e.typeno,
  791. corpId: e.corpId,
  792. corpName: e.corpName,
  793. unit: e.unit,
  794. size: e.size,
  795. price: 0,
  796. amount: 0,
  797. orderQuantity: 0,
  798. storageQuantity: e.storageQuantity,
  799. purchaseAmount: e.purchaseAmount,
  800. lotNo: e.batch == 1? this.form.lotNo: null,
  801. $cellEdit: true
  802. });
  803. });
  804. } else {
  805. this.selectionList.forEach(async e => {
  806. form = await this.getStockInfo({
  807. tradeType: 'JXS',
  808. goodsId: e.id,
  809. storageId: this.form.storageId,
  810. lotNo: e.batch == 1? this.form.lotNo: null
  811. })
  812. e.storageQuantity = form.stock;
  813. e.purchaseAmount = form.purchaseAmount;
  814. this.dataList.push({
  815. itemId: e.id,
  816. code: e.code,
  817. cname: e.cname,
  818. brandItem: e.brandItem,
  819. specsOne: e.specsOne,
  820. specsTwo: e.specsTwo,
  821. typeno: e.typeno,
  822. corpId: e.corpId,
  823. corpName: e.corpName,
  824. unit: e.unit,
  825. size: e.size,
  826. price: 0,
  827. amount: 0,
  828. orderQuantity: 0,
  829. storageQuantity: e.storageQuantity,
  830. purchaseAmount: e.purchaseAmount,
  831. lotNo: e.batch == 1? this.form.lotNo: null,
  832. $cellEdit: true
  833. });
  834. });
  835. }
  836. }
  837. this.dialogVisible = false;
  838. },
  839. closeGoods() {
  840. this.selectionList = [];
  841. this.treeDeptId = "";
  842. this.reData = null;
  843. this.activeName = 'searchList';
  844. this.goodsListSave = [];
  845. },
  846. nodeClick(data) {
  847. this.treeDeptId = data.id;
  848. this.page.currentPage = 1;
  849. this.onLoad(this.page);
  850. },
  851. //费用查询
  852. onLoad(page, params = {}) {
  853. let obj = this.deepClone(Object.assign(params, this.search));
  854. this.loading = true;
  855. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  856. .then(res => {
  857. const data = res.data.data;
  858. this.page.total = data.total;
  859. this.goodsList = data.records;
  860. if (this.page.total) {
  861. this.goodsOption.height = window.innerHeight - 350;
  862. }
  863. })
  864. .finally(() => {
  865. this.loading = false;
  866. });
  867. },
  868. searchChange(params, done) {
  869. this.search = this.deepClone(params);
  870. this.onLoad(this.page, params);
  871. done();
  872. },
  873. selectionChange(list) {
  874. this.selectionList = list;
  875. },
  876. rowClick(row) {
  877. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  878. },
  879. async saveGoodsColumn() {
  880. const inSave = await this.saveColumnData(
  881. this.getColumnName(83),
  882. this.goodsOption
  883. );
  884. if (inSave) {
  885. this.$message.success("保存成功");
  886. //关闭窗口
  887. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  888. this.$nextTick(() => {
  889. this.$refs.goodsCrud.doLayout()
  890. })
  891. }
  892. },
  893. async resetGoodsColumn() {
  894. this.goodsOption = goodsOption;
  895. const inSave = await this.delColumnData(
  896. this.getColumnName(83),
  897. goodsOption
  898. );
  899. if (inSave) {
  900. this.$nextTick(() => {
  901. this.$refs.goodsCrud.doLayout()
  902. })
  903. this.$message.success("重置成功");
  904. //关闭窗口
  905. setTimeout(() => {
  906. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  907. }, 1000);
  908. }
  909. },
  910. openReport() {},
  911. rowCell(row, index) {
  912. if (row.$cellEdit == true) {
  913. this.$set(row, "$cellEdit", false);
  914. } else {
  915. this.$set(row, "$cellEdit", true);
  916. }
  917. },
  918. rowDel(row, index) {
  919. this.$confirm("确定删除数据?", {
  920. confirmButtonText: "确定",
  921. cancelButtonText: "取消",
  922. type: "warning"
  923. }).then(() => {
  924. if (row.id) {
  925. removeGoods(row.id).then(res => {
  926. this.$message({
  927. type: 'success',
  928. message: '删除成功!'
  929. })
  930. this.dataList.splice(row.$index, 1);
  931. })
  932. } else {
  933. this.$message({
  934. type: "success",
  935. message: "删除成功!"
  936. });
  937. this.dataList.splice(row.$index, 1);
  938. }
  939. });
  940. },
  941. cnameChange(row) {
  942. let form = {};
  943. this.goodsoptions.forEach(async e => {
  944. if (e.id == row.itemId) {
  945. form = await this.getStockInfo({
  946. tradeType: 'JXS',
  947. goodsId: e.id,
  948. storageId: this.form.storageId,
  949. lotNo: e.batch == 1? this.form.lotNo: null
  950. })
  951. e.storageQuantity = form.stock;
  952. e.purchaseAmount = form.purchaseAmount;
  953. row.storageQuantity = res.data.data
  954. row.cname = e.cname;
  955. row.code = e.code;
  956. row.corpId = e.corpId;
  957. row.corpName = e.corpName;
  958. row.brandItem = e.brandItem;
  959. row.specsOne = e.specsOne;
  960. row.specsTwo = e.specsTwo;
  961. row.typeno = e.typeno;
  962. row.unit = e.unit;
  963. row.size = e.size;
  964. row.priceCategory = e.goodsTypeName;
  965. row.storageQuantity = e.storageQuantity;
  966. row.purchaseAmount = e.purchaseAmount;
  967. row.lotNo = e.batch == 1? this.form.lotNo: null;
  968. // row.amount = 0;
  969. }
  970. });
  971. },
  972. rePick(row, index) {
  973. this.reData = {
  974. ...row,
  975. index: index
  976. };
  977. this.newDetails();
  978. },
  979. // 商品信息价格计算
  980. amountChange(row) {
  981. if (!row.orderQuantity) {
  982. row.orderQuantity = 0;
  983. }
  984. if (!row.price) {
  985. row.price = 0;
  986. }
  987. row.amount = Number(row.price) * Number(row.orderQuantity)
  988. },
  989. // 标签页切换
  990. tabHandle(data) {
  991. if (data.name == 'searchList') {
  992. this.goodsListShow = this.goodsList;
  993. this.page.total = this.pageList.total
  994. } else if (data.name == 'importStaging') {
  995. this.goodsListShow = this.goodsListSave;
  996. this.page.total = 0
  997. }
  998. },
  999. removeStagList(row, index) {
  1000. this.goodsListSave.splice(row.$index, 1)
  1001. },
  1002. importStagList(row, index) {
  1003. this.goodsListSave.push(row);
  1004. },
  1005. // 生成结算
  1006. applySettlement(type) {
  1007. this.beforeBillData(true,type)
  1008. this.financialAccountDialog = true;
  1009. },
  1010. //生成账单 拿到主表信息
  1011. beforeBillData(bool,type) {
  1012. this.billType = type;
  1013. this.applyPaymentList = [];
  1014. this.dataList.map(e => {
  1015. const form = {
  1016. srcOrderno:this.form.orderNo,
  1017. srcParentId: this.form.id,
  1018. itemType:"采购",
  1019. corpsName:this.form.corpsName,
  1020. corpId:this.form.corpId,
  1021. currency: 'CNY',
  1022. exchangeRate: '1',
  1023. taxRate: '0',
  1024. accDate: this.form.businesDate,
  1025. srcType: 1,
  1026. // chargeMember: this.form.chargeMember,
  1027. parentId: this.form.id,
  1028. tradeType: 'JXS',
  1029. optionType: 'JXS',
  1030. amount: e.amount,
  1031. costType: this.feesOption.find(item => item.cname == '货款')? this.feesOption.find(item => item.cname == '货款').id: null,
  1032. srcFeesId: e.id,
  1033. cname: e.cname
  1034. }
  1035. this.applyPaymentList.push(form);
  1036. })
  1037. },
  1038. //关闭账单
  1039. choceFun(){
  1040. this.financialAccountDialog = false
  1041. },
  1042. // 获得库存信息
  1043. async getStockInfo(data) {
  1044. //tradeType JXS
  1045. //goodsId
  1046. //storageId
  1047. //lotNo 批次号
  1048. let form = {};
  1049. await getDetail(data).then(res => {
  1050. const a = res.data.data? res.data.data: {
  1051. stock: 0,
  1052. balanceAmount: 0,
  1053. balanceQuantity: 0,
  1054. };
  1055. this.$set(form, 'purchaseAmount', a.balanceQuantity == 0? 0: (Number(a.balanceAmount) / Number(a.balanceQuantity)).toFixed(2));
  1056. this.$set(form, 'stock', a.balanceQuantity);
  1057. })
  1058. return form;
  1059. },
  1060. // 确认或者取消订单
  1061. dealerSubmit() {
  1062. let dealer;
  1063. if (this.form.status == 0) {
  1064. dealer = 1;
  1065. } else if (this.form.status == 3) {
  1066. dealer = 2;
  1067. }
  1068. this.btnLoading = true;
  1069. dealerSubmit({
  1070. id: this.form.id,
  1071. dealer
  1072. }).then(res => {
  1073. if (res.data.code == 200) {
  1074. this.$message.success('操作成功')
  1075. this.queryData(this.form.id)
  1076. } else {
  1077. this.$message.error(res.data.msg)
  1078. }
  1079. }).finally(() => {
  1080. this.btnLoading = false;
  1081. })
  1082. },
  1083. },
  1084. }
  1085. </script>
  1086. <style lang="scss" scoped>
  1087. .trading-form ::v-deep .el-form-item {
  1088. margin-bottom: 8px !important;
  1089. }
  1090. ::v-deep .el-form-item__error {
  1091. display: none !important;
  1092. }
  1093. ::v-deep .select-component {
  1094. display: flex !important;
  1095. }
  1096. </style>