detail.vue 31 KB

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