detail.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  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. style="margin-right: 8px;"
  25. @click="dealerSubmit"
  26. :disabled="disabled"
  27. :loading="btnLoading"
  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. >生成账单
  39. </el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. <el-button
  43. type="success"
  44. :disabled="!form.id"
  45. size="small"
  46. @click="copyDoc"
  47. :loading="btnLoading"
  48. >
  49. 复制单据
  50. </el-button>
  51. <el-button
  52. type="primary"
  53. @click="editCustomer"
  54. size="small"
  55. :loading="btnLoading"
  56. :disabled="disabled"
  57. >保存数据
  58. </el-button>
  59. </div>
  60. </div>
  61. <div class="customer-main">
  62. <containerTitle title="基础信息"/>
  63. <basic-container :showBtn="true">
  64. <avue-form
  65. ref="form"
  66. class="trading-form"
  67. v-model="form"
  68. :option="option"
  69. >
  70. <template slot="corpId">
  71. <crop-select
  72. v-model="form.corpId"
  73. @getCorpData="getCorpData"
  74. corpType="KH"
  75. :disabled="disabled || confirmDisabled"
  76. />
  77. </template>
  78. <template slot="belongToCorpId">
  79. <crop-select
  80. v-model="form.belongToCorpId"
  81. @getCorpData="getGSData"
  82. corpType="GS"
  83. :disabled="disabled || confirmDisabled"
  84. />
  85. </template>
  86. <template slot="storageId">
  87. <warehouse-select
  88. v-model="form.storageId"
  89. @returnBack="storageChange"
  90. :configuration="configurationWarehouse"
  91. :disabled="disabled || confirmDisabled"/>
  92. </template>
  93. <template slot="chargeMember">
  94. <el-select
  95. v-model="form.chargeMember"
  96. filterable
  97. clearable
  98. size="small"
  99. :disabled="disabled"
  100. >
  101. <el-option
  102. v-for="(item,index) in userList"
  103. :key="index"
  104. :label="item.realName"
  105. :value="item.realName"
  106. ></el-option>
  107. </el-select>
  108. </template>
  109. </avue-form>
  110. </basic-container>
  111. <containerTitle title="商品信息"/>
  112. <basic-container>
  113. <avue-crud
  114. ref="crud"
  115. :data="dataList"
  116. :option="tableOption"
  117. :cell-style="cellStyle"
  118. @saveColumn="saveColumn"
  119. @resetColumn="resetColumn"
  120. >
  121. <template slot="headerSerial" slot-scope="{column}">
  122. <el-button type="primary" icon="el-icon-circle-plus-outline" circle size="mini" @click="$refs.crud.rowCellAdd()"></el-button>
  123. </template>
  124. <template slot="menuLeft">
  125. <el-button
  126. type="primary"
  127. icon="el-icon-plus"
  128. size="small"
  129. @click.stop="newDetails"
  130. :disabled="disabled || !form.storageId || confirmDisabled"
  131. >录入明细</el-button>
  132. <el-button
  133. type="info"
  134. icon="el-icon-printer"
  135. size="small"
  136. @click.stop="openReport"
  137. >报 表</el-button>
  138. <el-button
  139. type="primary"
  140. size="small"
  141. icon="el-icon-download"
  142. @click="downloadHandle"
  143. >下载模板</el-button>
  144. <el-upload
  145. :action="baseURL"
  146. :headers="headers"
  147. :disabled="disabled || confirmDisabled || !form.storageId"
  148. :on-progress="uploading"
  149. :show-file-list=false
  150. :data="uploadParam"
  151. accept=".xls,.xlsx"
  152. multiple
  153. :on-success="importTemplate"
  154. :on-error="uploadError"
  155. style="float: right"
  156. >
  157. <el-button
  158. type="primary"
  159. size="small"
  160. icon="el-icon-upload"
  161. :disabled="disabled || confirmDisabled || !form.storageId"
  162. >导 入</el-button>
  163. </el-upload>
  164. </template>
  165. <template slot="menu" slot-scope="{ row, index }">
  166. <el-button
  167. size="small"
  168. icon="el-icon-edit"
  169. type="text"
  170. @click="rowCell(row, index)"
  171. :disabled="disabled || confirmDisabled"
  172. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  173. >
  174. <el-button
  175. size="small"
  176. icon="el-icon-delete"
  177. type="text"
  178. @click="rowDel(row, index)"
  179. :disabled="disabled || confirmDisabled"
  180. >删除</el-button
  181. >
  182. </template>
  183. <template slot="code" slot-scope="{ row, index }">
  184. <span v-if="row.$cellEdit" style="display:flex">
  185. <el-select
  186. v-model="row.code"
  187. placeholder="请选择"
  188. filterable
  189. size="small"
  190. style="width:60%"
  191. @change="codeChange(row, index)"
  192. :disabled="!form.storageId"
  193. >
  194. <el-option
  195. v-for="item in goodsoptions"
  196. :key="item.id"
  197. :label="item.code"
  198. :value="item.code"
  199. >
  200. </el-option>
  201. </el-select>
  202. <el-button
  203. icon="el-icon-search"
  204. size="small"
  205. @click="rePick(row, index)"
  206. ></el-button>
  207. </span>
  208. <span v-else> {{ row.code }}</span>
  209. </template>
  210. <template slot="cname" slot-scope="{ row, index }">
  211. <span v-if="row.$cellEdit" style="display:flex">
  212. <el-select
  213. v-model="row.itemId"
  214. placeholder="请选择"
  215. size="small"
  216. filterable
  217. style="width:60%"
  218. @change="cnameChange(row, index)"
  219. :disabled="!form.storageId"
  220. >
  221. <el-option
  222. v-for="item in goodsoptions"
  223. :key="item.id"
  224. :label="item.cname"
  225. :value="item.id"
  226. >
  227. </el-option>
  228. </el-select>
  229. <el-button
  230. icon="el-icon-search"
  231. size="small"
  232. @click="rePick(row, index)"
  233. ></el-button>
  234. </span>
  235. <span v-else> {{ row.cname }}</span>
  236. </template>
  237. <template slot="orderQuantity" slot-scope="{ row, index }">
  238. <el-input-number
  239. v-if="row.$cellEdit"
  240. v-model="row.orderQuantity"
  241. size="small"
  242. :controls="false"
  243. :precision="0"
  244. @input="amountChange(row)"
  245. :disabled="!form.storageId"
  246. style="width: 100%"
  247. />
  248. <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
  249. </template>
  250. <template slot="price" slot-scope="{ row, index }">
  251. <el-input-number
  252. v-if="row.$cellEdit"
  253. v-model="row.price"
  254. size="small"
  255. :controls="false"
  256. :precision="2"
  257. @input="amountChange(row)"
  258. style="width: 100%"
  259. :disabled="!form.storageId"
  260. ></el-input-number>
  261. <span v-else>{{ row.price }}</span>
  262. </template>
  263. <!-- 单位-->
  264. <template slot="unit" slot-scope="{ row, index }">
  265. <el-select
  266. v-if="row.$cellEdit"
  267. v-model="row.unit"
  268. size="small"
  269. clearable
  270. filterable
  271. :disabled="!form.storageId"
  272. >
  273. <el-option
  274. v-for="(item, index) in unitOption"
  275. :key="index"
  276. :label="item.dictValue"
  277. :value="item.dictValue"
  278. />
  279. </el-select>
  280. <span v-else>{{ row.unit }}</span>
  281. </template>
  282. <template slot="amount" slot-scope="{ row, index }">
  283. <span>{{ row.amount | decimalFormat }}</span>
  284. </template>
  285. <template slot="storageQuantity" slot-scope="{ row, index }">
  286. <span>{{ row.storageQuantity | IntegerFormat }}</span>
  287. </template>
  288. <template slot="lotNo" slot-scope="{ row, index }">
  289. <span v-if="row.batch == 1" style="color: #c90707;margin-right: 3px">*</span>
  290. <el-select
  291. v-if="row.$cellEdit"
  292. v-model="row.lotNo"
  293. size="small"
  294. filterable
  295. allow-create
  296. clearable
  297. @change="lotNoChange(row)"
  298. :disabled="!form.storageId"
  299. >
  300. <el-option
  301. v-for="(item, index) in row.arr"
  302. :key="index"
  303. :label="item.lotNo"
  304. :value="item.lotNo"
  305. />
  306. </el-select>
  307. <span v-else>{{ row.lotNo }}</span>
  308. </template>
  309. <template slot="newJob" slot-scope="{ row, index }">
  310. <span style="color: #1e9fff;cursor: pointer" @click="openHistory(row)">{{ row.newJob }}</span>
  311. </template>
  312. <template slot="remarks" slot-scope="{ row, index }">
  313. <el-input
  314. v-if="row.$cellEdit"
  315. v-model="row.remarks"
  316. size="small"
  317. :disabled="!form.storageId"
  318. />
  319. <span v-else>{{ row.remarks }}</span>
  320. </template>
  321. </avue-crud>
  322. </basic-container>
  323. <containerTitle title="详细信息"/>
  324. <basic-container :showBtn="true">
  325. <avue-form
  326. ref="form1"
  327. class="trading-form"
  328. v-model="form"
  329. :option="detailOption"
  330. ></avue-form>
  331. </basic-container>
  332. <containerTitle title="附件管理"></containerTitle>
  333. <c-upload
  334. :data="uploadData"
  335. deleteUrl="/api/blade-client/corpsbank/update"
  336. :enumerationValue="84"
  337. :disabled="disabled || confirmDisabled"
  338. />
  339. </div>
  340. <!-- 商品弹窗-->
  341. <el-dialog
  342. title="导入商品"
  343. append-to-body
  344. class="el-dialogDeep"
  345. :visible.sync="dialogVisible"
  346. width="80%"
  347. :close-on-click-modal="false"
  348. :destroy-on-close="true"
  349. :close-on-press-escape="false"
  350. @close="closeGoods"
  351. top="5vh"
  352. v-dialog-drag
  353. >
  354. <span>
  355. <el-row>
  356. <el-col :span="4">
  357. <div>
  358. <el-scrollbar>
  359. <basic-container>
  360. <avue-tree
  361. :option="treeOption"
  362. @node-click="nodeClick"
  363. :style="treeStyle"
  364. />
  365. </basic-container>
  366. </el-scrollbar>
  367. </div>
  368. </el-col>
  369. <el-col :span="20">
  370. <avue-crud
  371. :option="goodsOption"
  372. :table-loading="loading"
  373. :data="goodsListShow"
  374. ref="goodsCrud"
  375. :search.sync="search"
  376. @search-change="searchChange"
  377. @selection-change="selectionChange"
  378. @row-click="rowClick"
  379. :page.sync="page"
  380. @on-load="onLoad"
  381. @saveColumn="saveGoodsColumn"
  382. @resetColumn="resetGoodsColumn"
  383. :cell-style="cellStyle"
  384. >
  385. <template slot="menuLeft">
  386. <el-tabs v-model="activeName" @tab-click="tabHandle">
  387. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  388. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  389. </el-tabs>
  390. </template>
  391. <template slot-scope="scope" slot="menu">
  392. <el-button
  393. type="text"
  394. icon="el-icon-edit"
  395. size="small"
  396. @click.stop="importStagList(scope.row,scope.index)"
  397. v-if="activeName=='searchList'"
  398. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
  399. >选择
  400. </el-button>
  401. <el-button
  402. type="text"
  403. icon="el-icon-delete"
  404. size="small"
  405. @click.stop="removeStagList(scope.row,scope.index)"
  406. v-else
  407. >移除
  408. </el-button>
  409. </template>
  410. </avue-crud>
  411. </el-col>
  412. </el-row>
  413. </span>
  414. <span slot="footer" class="dialog-footer">
  415. <el-button @click="dialogVisible = false">取 消</el-button>
  416. <el-button
  417. type="primary"
  418. @click="importGoods"
  419. :disabled="selectionList.length == 0 && goodsListSave.length == 0"
  420. >导入</el-button
  421. >
  422. </span>
  423. </el-dialog>
  424. <!-- 报表-->
  425. <report-dialog
  426. :switchDialog="switchDialog"
  427. :reportId="form.id"
  428. reportName="经销商-销售单"
  429. @onClose="onClose()"
  430. />
  431. <!-- 账单-->
  432. <el-dialog
  433. append-to-body
  434. title="账单"
  435. class="el-dialogDeep"
  436. :visible.sync="financialAccountDialog"
  437. width="70%"
  438. :close-on-click-modal="false"
  439. :destroy-on-close="true"
  440. :close-on-press-escape="false"
  441. v-dialog-drag
  442. >
  443. <financial-account
  444. :billType="billType"
  445. :billData="{}"
  446. :arrList="applyPaymentList"
  447. :belongCompany="form.belongToCorpId"
  448. @choceFun="choceFun"
  449. />
  450. </el-dialog>
  451. <!-- 历史记录-->
  452. <view-history
  453. v-if="historyVisible"
  454. ref="history"
  455. :params="historyParams"
  456. @closeDialog="closeDialog"
  457. />
  458. </div>
  459. </template>
  460. <script>
  461. import tableOption from "./config/customerContact.json";
  462. import goodsOption from "./config/commodity.json";
  463. import {getDeptLazyTree,
  464. getGoods,} from "@/api/basicData/customerInquiry";
  465. import {getUserInfo} from "@/api/system/user";
  466. import { gainUser } from "@/api/basicData/customerInquiry";
  467. import {selectGoodsNum} from "@/api/basicData/inventoryAccount"; // 库存查询
  468. import {detail as KHDetail} from "@/api/basicData/customerInformation";
  469. import {dataDetail, removeGoods, typeSave, getLotNo, dealerSubmit, historyPrice, itemDetail} from "@/api/dealer/sales";
  470. import reportDialog from "@/components/report-dialog/main";
  471. import {
  472. isDiscount,
  473. isPercentage,
  474. micrometerFormat,
  475. IntegerFormat
  476. } from "@/util/validate";
  477. import financialAccount from "../../../components/finance/financialAccount";
  478. import checkSchedule from "@/components/check/checkSchedule";
  479. import billApplication from "@/components/bill/billApplication";
  480. import { customerList as feeList } from "@/api/basicData/basicFeesDesc";
  481. import {getDetail} from "@/api/basicData/inventoryAccount";
  482. import { getToken } from "@/util/auth";
  483. import { getCurrentDate } from "@/util/date";
  484. import viewHistory from '../componet/history';
  485. import { getMarketPrice, getPurchasePrice } from "@/api/basicData/fees"
  486. export default {
  487. name: "detail",
  488. props: {
  489. detailData: {
  490. type: Object
  491. }
  492. },
  493. components: {
  494. reportDialog,
  495. billApplication,
  496. financialAccount,
  497. checkSchedule,
  498. viewHistory,
  499. },
  500. data() {
  501. return {
  502. orderNumber:true,
  503. pageLoading: false,
  504. btnLoading: false,
  505. disabled: false, // 编辑
  506. confirmDisabled: false, // 确认禁用
  507. form: {},
  508. option: {
  509. menuBtn: false,
  510. labelWidth: 100,
  511. column: [
  512. {
  513. label: "客户名称",
  514. prop: "corpId",
  515. rules: [
  516. {
  517. required: true,
  518. message: " ",
  519. trigger: "change"
  520. }
  521. ],
  522. span: 16,
  523. slot: true,
  524. },
  525. {
  526. label: "业务时间",
  527. prop: "businesDate",
  528. span: 8,
  529. type: "date",
  530. format: "yyyy-MM-dd",
  531. valueFormat: "yyyy-MM-dd 00:00:00",
  532. rules: [
  533. {
  534. required: true,
  535. message: "",
  536. trigger: "blur"
  537. }
  538. ]
  539. },
  540. {
  541. label: "所属公司",
  542. prop: "belongToCorpId",
  543. rules: [
  544. {
  545. required: true,
  546. message: " ",
  547. trigger: "change"
  548. }
  549. ],
  550. span: 16,
  551. slot: true,
  552. },
  553. {
  554. label: "发货仓库",
  555. prop: "storageId",
  556. span: 8,
  557. rules: [
  558. {
  559. required: true,
  560. message: " ",
  561. trigger: "change"
  562. }
  563. ],
  564. },
  565. {
  566. label: "电话",
  567. prop: "corpTel",
  568. span: 8,
  569. },
  570. {
  571. label: "地址",
  572. prop: "arrivalAddress",
  573. span: 8,
  574. },
  575. {
  576. label: "业务员",
  577. prop: "chargeMember",
  578. span: 8,
  579. },
  580. {
  581. label: "结算方式",
  582. prop: "paymentType",
  583. span: 8,
  584. type: "select",
  585. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  586. props: {
  587. label: "dictValue",
  588. value: "dictValue"
  589. },
  590. },
  591. {
  592. label: "配送方式",
  593. prop: "distributionMode",
  594. span: 8,
  595. },
  596. {
  597. label: "备注",
  598. prop: "orderRemark",
  599. type: "textarea",
  600. minRows: 2,
  601. span: 24,
  602. },
  603. ],
  604. },
  605. detailOption: {
  606. menuBtn: false,
  607. labelWidth: 100,
  608. column: [
  609. {
  610. label: "系统号",
  611. prop: "sysNo",
  612. span: 8,
  613. disabled: true
  614. },
  615. {
  616. label: "打印时间",
  617. prop: "printTime",
  618. span: 8,
  619. disabled: true
  620. },
  621. {
  622. label: "打印次数",
  623. prop: "printNumber",
  624. span: 8,
  625. disabled: true
  626. },
  627. {
  628. label: "客户欠款",
  629. prop: "corpDebt",
  630. span: 8,
  631. disabled: true
  632. },
  633. {
  634. label: "总数量",
  635. prop: "orderQuantity",
  636. span: 8,
  637. disabled: true
  638. },
  639. {
  640. label: "应收金额",
  641. prop: "debitAmount",
  642. span: 8,
  643. disabled: true
  644. },
  645. {
  646. label: "总金额",
  647. prop: "amount",
  648. span: 8,
  649. disabled: true
  650. },
  651. {
  652. label: "制单人",
  653. prop: "createUserName",
  654. span: 8,
  655. disabled: true,
  656. },
  657. ]
  658. },
  659. dataList: [],
  660. tableOption: {},
  661. dialogVisible: false,
  662. selectionList: [],
  663. treeDeptId: null,
  664. reData: null,
  665. treeOption: {
  666. nodeKey: "id",
  667. lazy: true,
  668. treeLoad: function(node, resolve) {
  669. const parentId = node.level === 0 ? 0 : node.data.id;
  670. getDeptLazyTree(parentId).then(res => {
  671. resolve(
  672. res.data.data.map(item => {
  673. return {
  674. ...item,
  675. leaf: !item.hasChildren
  676. };
  677. })
  678. );
  679. });
  680. },
  681. addBtn: false,
  682. menu: false,
  683. size: "small",
  684. props: {
  685. label: "title",
  686. value: "value",
  687. children: "children"
  688. }
  689. },
  690. page: {
  691. pageSize: 10,
  692. currentPage: 1,
  693. total: 0
  694. },
  695. search: {},
  696. goodsList: [],
  697. loading: false,
  698. goodsOption: {},
  699. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  700. goodsoptions: [],
  701. // 仓库配置
  702. configurationWarehouse: {
  703. multipleChoices: false,
  704. multiple: false,
  705. collapseTags: false,
  706. placeholder: "请点击右边按钮选择",
  707. dicData: [],
  708. },
  709. uploadData: [],
  710. goodData: [], // 存储所有商品信息
  711. switchDialog: false, // 报表弹窗控制
  712. userList: [],
  713. activeName: 'searchList',
  714. // 商品列表数据合计
  715. goodsListShow: [],
  716. // 商品列表暂存
  717. goodsListSave: [],
  718. pageList: {
  719. pageSize: 10,
  720. currentPage: 1,
  721. total: 0
  722. },
  723. applyPaymentList: [],
  724. billType:"收费", //账单类型
  725. billData:{}, //账单需要数据
  726. applySettlementDialog:false,//生成账单组件
  727. financialAccountDialog:false,
  728. feesOption: [],
  729. unitOption: [],
  730. baseURL: '/api/blade-purchase-sales/orderitems/importDealerOrder',
  731. headers: { "Blade-Auth": 'Bearer ' + getToken()},
  732. uploadParam: {},
  733. historyVisible: false,
  734. historyParams: {},
  735. }
  736. },
  737. async created() {
  738. this.getWorkDicts('unit').then(res => {
  739. this.unitOption = res.data.data;
  740. })
  741. this.tableOption = await this.getColumnData(
  742. this.getColumnName(79),
  743. tableOption
  744. );
  745. this.goodsOption = await this.getColumnData(
  746. this.getColumnName(80),
  747. goodsOption
  748. );
  749. getGoods(1, 10).then(res => {
  750. if (res.data.data.total > 0) {
  751. this.goodsoptions = res.data.data.records;
  752. if (Math.ceil(res.data.data.total / 10) > 1) {
  753. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  754. getGoods(i, 10).then(e => {
  755. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  756. });
  757. }
  758. }
  759. }
  760. });
  761. getUserInfo().then(res => {
  762. this.$set(this.form, 'createUserName', res.data.data.realName)
  763. this.$set(this.form, 'createUser', res.data.data.id)
  764. })
  765. gainUser().then(res => {
  766. this.userList = res.data.data;
  767. });
  768. feeList().then(res => {
  769. this.feesOption = res.data.data.records
  770. });
  771. this.$set(this.form, 'businesDate', getCurrentDate());
  772. this.$set(this.form, 'status', 0);
  773. if (this.detailData.query) {
  774. this.disabled = true;
  775. this.option.column.map(e => {
  776. this.$set(e, 'disabled', true)
  777. })
  778. this.queryData(this.detailData.id);
  779. } else {
  780. this.dataList = [
  781. {
  782. code: null,
  783. cname: null,
  784. typeno: null,
  785. brandItem: null,
  786. specsOne: null,
  787. specsTwo: null,
  788. unit: null,
  789. storageQuantity: 0,
  790. orderQuantity: 0,
  791. size: null,
  792. price: 0,
  793. amount: 0,
  794. $cellEdit: true
  795. }
  796. ]
  797. }
  798. },
  799. filters: {
  800. IntegerFormat(num) {
  801. return IntegerFormat(num);
  802. },
  803. decimalFormat(num) {
  804. return num ? Number(num).toFixed(2) : "0.00";
  805. }
  806. },
  807. methods: {
  808. // 查询
  809. queryData(id) {
  810. this.pageLoading = true;
  811. dataDetail(id).then(res => {
  812. this.form = res.data.data;
  813. this.form.amount = Number(this.form.amount).toFixed(2);
  814. if (this.form.storageId) {
  815. this.uploadParam = {
  816. storageId: this.form.storageId
  817. }
  818. }
  819. this.confirmDisabled = this.form.status == 3? true: false;
  820. if (this.confirmDisabled) {
  821. // this.option.column.map(e => {
  822. // this.$set(e, 'disabled', true)
  823. // })
  824. }
  825. this.dataList = this.form.orderItemsList? this.form.orderItemsList: [];
  826. this.uploadData = this.form.orderFilesList? this.form.orderFilesList: [];
  827. delete this.form.orderItemsList;
  828. delete this.form.orderFilesList;
  829. this.dataList.forEach(async item => {
  830. if (item.batch == 1) {
  831. item.arr = await this.getLotNo({
  832. itemId: item.itemId,
  833. storageId: this.form.storageId,
  834. tradeType: 'JXS'
  835. });
  836. }
  837. })
  838. }).finally(() => {
  839. this.pageLoading = false;
  840. })
  841. },
  842. cellStyle() {
  843. return "padding:0;height:40px;";
  844. },
  845. openEdit() {
  846. this.disabled = false;
  847. this.option.column.map(e => {
  848. if (this.confirmDisabled) {
  849. if (e.prop == 'businesDate') {
  850. this.$set(e, 'disabled', true)
  851. } else {
  852. this.$set(e, 'disabled', false)
  853. }
  854. } else {
  855. this.$set(e, 'disabled', false)
  856. }
  857. })
  858. },
  859. copyDoc() {
  860. this.$emit("copyOrder", this.form.id);
  861. },
  862. getCorpData(row) {
  863. KHDetail(row.id).then(res => {
  864. if (res.data.data.belongtocompany) {
  865. this.$set(this.form, 'belongToCorpId', res.data.data.belongtocompany)
  866. } else {
  867. this.$set(this.form, 'belongToCorpId', null)
  868. }
  869. })
  870. },
  871. getGSData(row) {},
  872. //修改提交触发
  873. editCustomer(status) {
  874. this.$refs["form"].validate((valid, done) => {
  875. done();
  876. if (valid) {
  877. for (let item in this.dataList) {
  878. if (this.dataList[item].batch == 1 && !this.dataList[item].lotNo) {
  879. return this.$message.error('第' +( Number(item) + 1) + '行明细批次号未填写')
  880. }
  881. }
  882. // 总金额计算
  883. let amount = 0;
  884. this.dataList.forEach((item, index) => {
  885. if (item.batch == 1 && !item.lotNo) {
  886. }
  887. amount = Number(amount) + Number(item.amount)
  888. })
  889. this.$set(this.form, 'debitAmount', amount.toFixed(2));
  890. this.$set(this.form, 'amount', amount.toFixed(2));
  891. this.form.billType = 'XS';
  892. this.$set(this.form, 'orderItemsList', this.dataList);
  893. this.$set(this.form, 'orderFilesList', this.uploadData);
  894. this.btnLoading = true;
  895. typeSave(this.form).then(res => {
  896. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  897. this.queryData(res.data.data.id);
  898. }).finally(() => {
  899. this.btnLoading = false;
  900. })
  901. } else {
  902. return false
  903. }
  904. })
  905. },
  906. //返回列表
  907. backToList() {
  908. this.$emit("goBack");
  909. },
  910. async saveColumn() {
  911. const inSave = await this.saveColumnData(
  912. this.getColumnName(79),
  913. this.tableOption
  914. );
  915. if (inSave) {
  916. this.$message.success("保存成功");
  917. //关闭窗口
  918. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  919. this.$nextTick(() => {
  920. this.$refs.crud.doLayout()
  921. })
  922. }
  923. },
  924. async resetColumn() {
  925. this.tableOption = tableOption;
  926. const inSave = await this.delColumnData(
  927. this.getColumnName(79),
  928. tableOption
  929. );
  930. if (inSave) {
  931. this.$nextTick(() => {
  932. this.$refs.crud.doLayout()
  933. })
  934. this.$message.success("重置成功");
  935. //关闭窗口
  936. setTimeout(() => {
  937. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  938. }, 1000);
  939. }
  940. },
  941. //商品明细导入
  942. newDetails() {
  943. this.$refs["form"].validate((valid) => {
  944. if (valid) {
  945. this.dialogVisible = !this.dialogVisible;
  946. }
  947. })
  948. },
  949. // 获得库存价
  950. async getStockInfo(data) {
  951. //tradeType JXS
  952. //goodsId
  953. //storageId
  954. //lotNo 批次号
  955. let form = {};
  956. await getDetail(data).then(res => {
  957. const a = res.data.data? res.data.data: {
  958. stock: 0,
  959. balanceAmount: 0,
  960. balanceQuantity: 0,
  961. };
  962. this.$set(form, 'purchaseAmount', a.balanceQuantity == 0? 0: (Number(a.balanceAmount) / Number(a.balanceQuantity)).toFixed(2));
  963. this.$set(form, 'stock', a.balanceQuantity);
  964. })
  965. return form;
  966. },
  967. // 获得批次号
  968. async getLotNo(data) {
  969. let arr = [];
  970. await getLotNo(data).then(res => {
  971. arr = res.data.data? res.data.data: []
  972. })
  973. return arr;
  974. },
  975. importGoods() {
  976. let form = {};
  977. if (this.reData) {
  978. if (this.selectionList.length != 1) {
  979. return this.$message.error("重新选择的时候只能选择一条数据");
  980. } else {
  981. this.selectionList.forEach(e => {
  982. this.dataList.forEach(async (item, index) => {
  983. if (index == this.reData.index) {
  984. getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
  985. if (response.data.data.length > 0) {
  986. this.$set(e, 'price', response.data.data[0].salePrice)
  987. } else {
  988. this.$set(e, 'price', '0')
  989. }
  990. })
  991. let historyData = await this.getHistoryData(e, 1); // 获得最新数据
  992. if (historyData.length > 0) {
  993. e.newJob = historyData[0].price;
  994. e.newDate = historyData[0].businesDate;
  995. } else {
  996. e.newJob = null;
  997. e.newDate = null;
  998. }
  999. if (e.batch == 0) {
  1000. form = await this.getStockInfo({
  1001. tradeType: 'JXS',
  1002. goodsId: e.id,
  1003. storageId: this.form.storageId,
  1004. })
  1005. item.storageQuantity = form.stock;
  1006. item.purchaseAmount = form.purchaseAmount;
  1007. } else {
  1008. item.storageQuantity = 0
  1009. item.purchaseAmount = 0;
  1010. item.arr = await this.getLotNo({
  1011. itemId: e.id,
  1012. storageId: this.form.storageId,
  1013. tradeType: 'JXS'
  1014. });
  1015. }
  1016. item.itemId = e.id;
  1017. item.code = e.code;
  1018. item.cname = e.cname;
  1019. item.corpId = e.corpId;
  1020. item.corpName = e.corpName;
  1021. item.brandItem = e.brandItem;
  1022. item.specsOne = e.specsOne;
  1023. item.specsTwo = e.specsTwo;
  1024. item.typeno = e.typeno;
  1025. item.unit = e.unit;
  1026. item.size = e.size;
  1027. item.priceCategory = e.goodsTypeName;
  1028. item.purchaseAmount = e.purchaseAmount;
  1029. item.batch = e.batch;
  1030. item.newDate = e.newDate;
  1031. item.newJob = e.newJob;
  1032. item.price = e.price;
  1033. item.$cellEdit = true;
  1034. }
  1035. });
  1036. });
  1037. }
  1038. } else {
  1039. if (this.goodsListSave.length > 0) { // 暂存的有数据
  1040. this.goodsListSave.forEach(async e => {
  1041. getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
  1042. if (response.data.data.length > 0) {
  1043. this.$set(e, 'price', response.data.data[0].salePrice)
  1044. } else {
  1045. this.$set(e, 'price', '0')
  1046. }
  1047. })
  1048. let historyData = await this.getHistoryData(e, 1); // 获得最新数据
  1049. if (historyData.length > 0) {
  1050. e.newJob = historyData[0].price;
  1051. e.newDate = historyData[0].businesDate;
  1052. } else {
  1053. e.newJob = null;
  1054. e.newDate = null;
  1055. }
  1056. if (e.batch == 0) {
  1057. form = await this.getStockInfo({
  1058. tradeType: 'JXS',
  1059. goodsId: e.id,
  1060. storageId: this.form.storageId,
  1061. })
  1062. e.storageQuantity = form.stock;
  1063. e.purchaseAmount = form.purchaseAmount;
  1064. e.arr = [];
  1065. } else {
  1066. e.storageQuantity = 0
  1067. e.purchaseAmount = 0;
  1068. e.arr = await this.getLotNo({
  1069. itemId: e.id,
  1070. storageId: this.form.storageId,
  1071. tradeType: 'JXS'
  1072. });
  1073. }
  1074. this.dataList.push({
  1075. itemId: e.id,
  1076. code: e.code,
  1077. cname: e.cname,
  1078. brandItem: e.brandItem,
  1079. specsOne: e.specsOne,
  1080. specsTwo: e.specsTwo,
  1081. typeno: e.typeno,
  1082. corpId: e.corpId,
  1083. corpName: e.corpName,
  1084. unit: e.unit,
  1085. size: e.size,
  1086. price: e.price,
  1087. amount: 0,
  1088. orderQuantity: 0,
  1089. storageQuantity: e.storageQuantity,
  1090. purchaseAmount: e.purchaseAmount,
  1091. batch: e.batch,
  1092. arr: e.arr,
  1093. newJob:e.newJob,
  1094. newDate: e.newDate,
  1095. $cellEdit: true
  1096. });
  1097. });
  1098. } else {
  1099. this.selectionList.forEach(async e => {
  1100. getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
  1101. if (response.data.data.length > 0) {
  1102. this.$set(e, 'price', response.data.data[0].salePrice)
  1103. } else {
  1104. this.$set(e, 'price', '0')
  1105. }
  1106. })
  1107. let historyData = await this.getHistoryData(e, 1); // 获得最新数据
  1108. if (historyData.length > 0) {
  1109. e.newJob = historyData[0].price;
  1110. e.newDate = historyData[0].businesDate;
  1111. } else {
  1112. e.newJob = null;
  1113. e.newDate = null;
  1114. }
  1115. if (e.batch == 0) {
  1116. form = await this.getStockInfo({
  1117. tradeType: 'JXS',
  1118. goodsId: e.id,
  1119. storageId: this.form.storageId,
  1120. })
  1121. e.storageQuantity = form.stock;
  1122. e.purchaseAmount = form.purchaseAmount;
  1123. e.arr = [];
  1124. } else {
  1125. e.storageQuantity = 0
  1126. e.purchaseAmount = 0;
  1127. e.arr = await this.getLotNo({
  1128. itemId: e.id,
  1129. storageId: this.form.storageId,
  1130. tradeType: 'JXS'
  1131. });
  1132. }
  1133. this.dataList.push({
  1134. itemId: e.id,
  1135. code: e.code,
  1136. cname: e.cname,
  1137. brandItem: e.brandItem,
  1138. specsOne: e.specsOne,
  1139. specsTwo: e.specsTwo,
  1140. typeno: e.typeno,
  1141. corpId: e.corpId,
  1142. corpName: e.corpName,
  1143. unit: e.unit,
  1144. size: e.size,
  1145. amount: 0,
  1146. orderQuantity: 0,
  1147. storageQuantity: e.storageQuantity,
  1148. purchaseAmount: e.purchaseAmount,
  1149. batch: e.batch,
  1150. arr: e.arr,
  1151. newJob: e.newJob,
  1152. newDate: e.newDate,
  1153. price: e.price,
  1154. $cellEdit: true
  1155. });
  1156. });
  1157. }
  1158. }
  1159. this.dialogVisible = false;
  1160. },
  1161. closeGoods() {
  1162. this.selectionList = [];
  1163. this.treeDeptId = "";
  1164. this.reData = null;
  1165. this.activeName = 'searchList';
  1166. this.goodsListSave = [];
  1167. },
  1168. nodeClick(data) {
  1169. this.treeDeptId = data.id;
  1170. this.page.currentPage = 1;
  1171. this.onLoad(this.page);
  1172. },
  1173. //商品查询
  1174. onLoad(page, params = {}) {
  1175. let obj = this.deepClone(Object.assign(params, this.search));
  1176. this.loading = true;
  1177. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  1178. .then(res => {
  1179. const data = res.data.data;
  1180. this.page.total = data.total;
  1181. this.goodsList = data.records;
  1182. this.pageList.total = data.total;
  1183. this.goodsListShow = data.records;
  1184. if (this.page.total) {
  1185. this.goodsOption.height = window.innerHeight - 350;
  1186. }
  1187. })
  1188. .finally(() => {
  1189. this.loading = false;
  1190. });
  1191. },
  1192. searchChange(params, done) {
  1193. this.search = this.deepClone(params);
  1194. this.onLoad(this.page, params);
  1195. done();
  1196. },
  1197. selectionChange(list) {
  1198. this.selectionList = list;
  1199. },
  1200. rowClick(row) {
  1201. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  1202. },
  1203. async saveGoodsColumn() {
  1204. const inSave = await this.saveColumnData(
  1205. this.getColumnName(80),
  1206. this.goodsOption
  1207. );
  1208. if (inSave) {
  1209. this.$message.success("保存成功");
  1210. //关闭窗口
  1211. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1212. this.$nextTick(() => {
  1213. this.$refs.goodsCrud.doLayout()
  1214. })
  1215. }
  1216. },
  1217. async resetGoodsColumn() {
  1218. this.goodsOption = goodsOption;
  1219. const inSave = await this.delColumnData(
  1220. this.getColumnName(80),
  1221. goodsOption
  1222. );
  1223. if (inSave) {
  1224. this.$nextTick(() => {
  1225. this.$refs.goodsCrud.doLayout()
  1226. })
  1227. this.$message.success("重置成功");
  1228. //关闭窗口
  1229. setTimeout(() => {
  1230. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1231. }, 1000);
  1232. }
  1233. },
  1234. // 报表
  1235. openReport() {
  1236. this.switchDialog =! this.switchDialog;
  1237. },
  1238. // 报表关闭
  1239. onClose(val) {
  1240. this.switchDialog = val;
  1241. },
  1242. rowCell(row, index) {
  1243. if (row.$cellEdit == true) {
  1244. this.$set(row, "$cellEdit", false);
  1245. } else {
  1246. this.$set(row, "$cellEdit", true);
  1247. }
  1248. },
  1249. rowDel(row, index) {
  1250. this.$confirm("确定删除数据?", {
  1251. confirmButtonText: "确定",
  1252. cancelButtonText: "取消",
  1253. type: "warning"
  1254. }).then(() => {
  1255. if (row.id) {
  1256. removeGoods(row.id).then(res => {
  1257. this.$message({
  1258. type: 'success',
  1259. message: '删除成功!'
  1260. })
  1261. this.dataList.splice(row.$index, 1);
  1262. })
  1263. } else {
  1264. this.$message({
  1265. type: "success",
  1266. message: "删除成功!"
  1267. });
  1268. this.dataList.splice(row.$index, 1);
  1269. }
  1270. });
  1271. },
  1272. codeChange(row) {
  1273. let form = {};
  1274. this.goodsoptions.forEach(async e => {
  1275. if (e.code == row.code) {
  1276. getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
  1277. if (response.data.data.length > 0) {
  1278. this.$set(e, 'price', response.data.data[0].salePrice)
  1279. } else {
  1280. this.$set(e, 'price', '0')
  1281. }
  1282. this.$set(row, 'amount', (Number(e.price) * Number(row.orderQuantity)).toFixed(2))
  1283. })
  1284. let historyData = await this.getHistoryData(e, 1); // 获得最新数据
  1285. if (historyData.length > 0) {
  1286. e.newJob = historyData[0].price;
  1287. e.newDate = historyData[0].businesDate;
  1288. } else {
  1289. e.newJob = null;
  1290. e.newDate = null;
  1291. }
  1292. if (e.batch == 0) {
  1293. form = await this.getStockInfo({
  1294. tradeType: 'JXS',
  1295. goodsId: e.id,
  1296. storageId: this.form.storageId,
  1297. })
  1298. e.storageQuantity = form.stock;
  1299. e.purchaseAmount = form.purchaseAmount;
  1300. e.arr = [];
  1301. } else {
  1302. e.storageQuantity = 0
  1303. e.purchaseAmount = 0;
  1304. e.arr = await this.getLotNo({
  1305. itemId: e.id,
  1306. storageId: this.form.storageId,
  1307. tradeType: 'JXS'
  1308. });
  1309. }
  1310. row.itemId = e.id;
  1311. row.storageQuantity = e.storageQuantity;
  1312. row.cname = e.cname;
  1313. row.code = e.code;
  1314. row.corpId = e.corpId;
  1315. row.corpName = e.corpName;
  1316. row.brandItem = e.brandItem;
  1317. row.specsOne = e.specsOne;
  1318. row.specsTwo = e.specsTwo;
  1319. row.typeno = e.typeno;
  1320. row.unit = e.unit;
  1321. row.size = e.size;
  1322. row.arr = e.arr;
  1323. row.priceCategory = e.goodsTypeName;
  1324. row.purchaseAmount = e.purchaseAmount;
  1325. row.batch = e.batch;
  1326. row.newJob = e.newJob;
  1327. row.newDate = e.newDate;
  1328. row.price = e.price;
  1329. }
  1330. });
  1331. },
  1332. cnameChange(row) {
  1333. let form = {};
  1334. this.goodsoptions.forEach(async e => {
  1335. if (e.id == row.itemId) {
  1336. getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
  1337. if (response.data.data.length > 0) {
  1338. this.$set(e, 'price', response.data.data[0].salePrice)
  1339. } else {
  1340. this.$set(e, 'price', '0')
  1341. }
  1342. this.$set(row, 'amount', (Number(e.price) * Number(row.orderQuantity)).toFixed(2))
  1343. })
  1344. let historyData = await this.getHistoryData(e, 1); // 获得最新数据
  1345. if (historyData.length > 0) {
  1346. e.newJob = historyData[0].price;
  1347. e.newDate = historyData[0].businesDate;
  1348. } else {
  1349. e.newJob = null;
  1350. e.newDate = null;
  1351. }
  1352. if (e.batch == 0) {
  1353. form = await this.getStockInfo({
  1354. tradeType: 'JXS',
  1355. goodsId: e.id,
  1356. storageId: this.form.storageId,
  1357. })
  1358. e.storageQuantity = form.stock;
  1359. e.purchaseAmount = form.purchaseAmount;
  1360. e.arr = [];
  1361. } else {
  1362. e.storageQuantity = 0
  1363. e.purchaseAmount = 0;
  1364. e.arr = await this.getLotNo({
  1365. itemId: e.id,
  1366. storageId: this.form.storageId,
  1367. tradeType: 'JXS'
  1368. });
  1369. }
  1370. row.storageQuantity = e.storageQuantity
  1371. row.cname = e.cname;
  1372. row.code = e.code;
  1373. row.corpId = e.corpId;
  1374. row.corpName = e.corpName;
  1375. row.brandItem = e.brandItem;
  1376. row.specsOne = e.specsOne;
  1377. row.specsTwo = e.specsTwo;
  1378. row.typeno = e.typeno;
  1379. row.unit = e.unit;
  1380. row.size = e.size;
  1381. row.arr = e.arr;
  1382. row.priceCategory = e.goodsTypeName;
  1383. row.purchaseAmount = e.purchaseAmount;
  1384. row.batch = e.batch;
  1385. row.newDate = e.newDate;
  1386. row.newJob = e.newJob;
  1387. row.price = e.price;
  1388. }
  1389. });
  1390. },
  1391. rePick(row, index) {
  1392. this.reData = {
  1393. ...row,
  1394. index: index
  1395. };
  1396. this.newDetails();
  1397. },
  1398. // 商品信息价格计算
  1399. amountChange(row) {
  1400. if (!row.orderQuantity) {
  1401. row.orderQuantity = 0;
  1402. }
  1403. if (!row.price) {
  1404. row.price = 0;
  1405. }
  1406. row.amount = Number(row.price) * Number(row.orderQuantity)
  1407. },
  1408. // 标签页切换
  1409. tabHandle(data) {
  1410. if (data.name == 'searchList') {
  1411. this.goodsListShow = this.goodsList;
  1412. this.page.total = this.pageList.total
  1413. } else if (data.name == 'importStaging') {
  1414. this.goodsListShow = this.goodsListSave;
  1415. this.page.total = 0
  1416. }
  1417. },
  1418. removeStagList(row, index) {
  1419. this.goodsListSave.splice(row.$index, 1)
  1420. },
  1421. importStagList(row, index) {
  1422. this.goodsListSave.push(row);
  1423. },
  1424. // 生成结算
  1425. applySettlement(type) {
  1426. this.beforeBillData(true,type)
  1427. this.financialAccountDialog = true;
  1428. },
  1429. //生成账单 拿到主表信息
  1430. beforeBillData(bool,type) {
  1431. this.billType = type;
  1432. this.applyPaymentList = [];
  1433. this.dataList.map(e => {
  1434. const form = {
  1435. srcOrderno:this.form.orgOrderNo,
  1436. srcParentId: this.form.id,
  1437. itemType:"销售",
  1438. corpsName:this.form.corpName,
  1439. corpId:this.form.corpId,
  1440. currency: 'CNY',
  1441. exchangeRate: '1',
  1442. taxRate: '0',
  1443. accDate: this.form.businesDate,
  1444. srcType: 1,
  1445. chargeMember: this.form.chargeMember,
  1446. parentId: this.form.id,
  1447. tradeType: 'JXS',
  1448. optionType: 'JXS',
  1449. amount: e.amount,
  1450. costType: this.feesOption.find(item => item.cname == '货款')? this.feesOption.find(item => item.cname == '货款').id: null,
  1451. srcFeesId: e.id,
  1452. goodName: e.cname,
  1453. price: e.price,
  1454. quantity: e.orderQuantity,
  1455. unit: e.unit,
  1456. }
  1457. this.applyPaymentList.push(form);
  1458. })
  1459. },
  1460. //关闭账单
  1461. choceFun(){
  1462. this.financialAccountDialog = false
  1463. },
  1464. // 批次号选择
  1465. async lotNoChange(row) {
  1466. if (row.lotNo) {
  1467. const form = await this.getStockInfo({
  1468. tradeType: 'JXS',
  1469. goodsId: row.itemId,
  1470. storageId: this.form.storageId,
  1471. lotNo: row.lotNo
  1472. })
  1473. row.storageQuantity = form.stock;
  1474. row.purchaseAmount = form.purchaseAmount;
  1475. } else {
  1476. row.storageQuantity = 0;
  1477. row.purchaseAmount = 0;
  1478. }
  1479. },
  1480. // 确认或者取消订单
  1481. dealerSubmit() {
  1482. let dealer;
  1483. if (this.form.status == 0) {
  1484. dealer = 1;
  1485. } else if (this.form.status == 3) {
  1486. dealer = 2;
  1487. }
  1488. this.btnLoading = true;
  1489. dealerSubmit({
  1490. id: this.form.id,
  1491. dealer
  1492. }).then(res => {
  1493. if (res.data.code == 200) {
  1494. this.$message.success('操作成功')
  1495. this.queryData(this.form.id)
  1496. } else {
  1497. this.$message.error(res.data.msg)
  1498. }
  1499. }).finally(() => {
  1500. this.btnLoading = false;
  1501. })
  1502. },
  1503. // 下载模板
  1504. downloadHandle() {
  1505. this.$confirm('是否下载模板文件?', '提示', {
  1506. confirmButtonText: '确定',
  1507. cancelButtonText: '取消',
  1508. type: 'warning'
  1509. }).then(() => {
  1510. window.open(
  1511. `/api/blade-purchase-sales/orderitems/exportDealerOrder?${
  1512. this.website.tokenHeader
  1513. }=${getToken()}`
  1514. );
  1515. }).catch(() => {
  1516. this.$message({
  1517. type: 'info',
  1518. message: '已取消'
  1519. });
  1520. })
  1521. },
  1522. //文件上传时
  1523. uploading(event, file, fileList) {
  1524. this.openFullScreen(false, '文件正在解析中');
  1525. },
  1526. importTemplate(res, file) {
  1527. this.openFullScreen(true)
  1528. res.data.forEach(item => {
  1529. })
  1530. this.dataList = this.dataList.concat(res.data)
  1531. },
  1532. uploadError(err, file, fileList) {
  1533. this.openFullScreen(true)
  1534. this.$message.error(JSON.parse(err.message).msg)
  1535. },
  1536. //遮罩层
  1537. openFullScreen(res, text) {
  1538. const loading = this.$loading({
  1539. lock: true,
  1540. text: text,
  1541. spinner: 'el-icon-loading',
  1542. background: 'rgba(0, 0, 0, 0.7)'
  1543. });
  1544. if (res === true) loading.close();
  1545. },
  1546. // 仓库选择
  1547. storageChange(value) {
  1548. if (this.form.storageId) {
  1549. this.uploadParam = {
  1550. storageId: value
  1551. }
  1552. }
  1553. },
  1554. // 获得历史数据
  1555. async getHistoryData(row, typeId = null) {
  1556. let data;
  1557. const params = {
  1558. typeId,
  1559. tradeType: 'JXS',
  1560. billType: 'XS',
  1561. itemId: row.id
  1562. }
  1563. await historyPrice(params).then(res => {
  1564. data = res.data.data? res.data.data: [];
  1565. })
  1566. return data;
  1567. },
  1568. openHistory(row) {
  1569. this.historyParams = {
  1570. tradeType: 'JXS',
  1571. billType: 'XS',
  1572. itemId: row.itemId
  1573. }
  1574. this.historyVisible = true;
  1575. this.$nextTick(() => {
  1576. this.$refs.history.init();
  1577. })
  1578. },
  1579. closeDialog() {
  1580. this.historyVisible = false;
  1581. },
  1582. // 销售金额获取
  1583. async getMarketPrice(row) {
  1584. await getMarketPrice({code: row.code}).then(res => {
  1585. this.salesPriceOtion = res.data.data
  1586. })
  1587. },
  1588. },
  1589. }
  1590. </script>
  1591. <style lang="scss" scoped>
  1592. .trading-form ::v-deep .el-form-item {
  1593. margin-bottom: 8px !important;
  1594. }
  1595. ::v-deep .el-form-item__error {
  1596. display: none !important;
  1597. }
  1598. ::v-deep .select-component {
  1599. display: flex !important;
  1600. }
  1601. </style>