detail.vue 49 KB

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