detail.vue 52 KB

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