detailsPageEdit.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <el-button
  11. class="el-button--small-yh add-customer-btn"
  12. style="right: 245px;"
  13. type="primary"
  14. @click="revokeInGoods"
  15. v-if="form.deliveryStatus !== '录入'"
  16. >撤销收货</el-button>
  17. <el-button
  18. class="el-button--small-yh add-customer-btn"
  19. style="right: 245px;"
  20. type="primary"
  21. @click="sendInGoods"
  22. v-if="form.deliveryStatus == '录入'"
  23. >确认收货</el-button>
  24. <el-button
  25. class="el-button--small-yh add-customer-btn"
  26. type="success" style="right: 140px;" @click="copyOrder">
  27. 复制新单
  28. </el-button>
  29. <el-button
  30. class="el-button--small-yh add-customer-btn"
  31. type="primary"
  32. :disabled="disabled"
  33. @click="editCustomer(false)"
  34. >{{ form.id ? '确认修改' : '确认新增' }}
  35. </el-button>
  36. </div>
  37. <div style="margin-top: 60px">
  38. <el-form :model="form" ref="form" label-width="130px" class="demo-ruleForm">
  39. <containerTitle title="基础资料"></containerTitle>
  40. <basic-container style="margin-bottom: 10px">
  41. <el-row>
  42. <el-col v-for="(item,index) in basicData.column" :key="index" :span="item.span?item.span:8">
  43. <el-form-item :label="item.label" :prop="item.prop" :rules="item.rules">
  44. <!-- <avue-input-tree v-if="item.prop === 'corpsTypeId'" leaf-only multiple :props="{label:'title'}" v-model="form[item.prop]" placeholder="请选择内容" type="tree" :dic="dic"-->
  45. <!-- ></avue-input-tree>-->
  46. <el-date-picker v-if="item.type === 'datetime'" style="width: 100%;" v-model="form[item.prop]"
  47. size="small" type="datetime" placeholder="选择日期" value-format="yyyy-MM-dd HH:mm:ss"/>
  48. <selectComponent v-else-if="item.prop === 'corpId' || item.prop === 'salesCompany'" v-model="form[item.prop]"
  49. :configuration="configuration" style="width: 100%"/>
  50. <el-select v-else-if="item.prop === 'purchaseMode'" v-model="form[item.prop]" placeholder="请选择" clearable filterable style="width: 100%" size="small">
  51. <el-option v-for="(item,index) in procurementMethodOption" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  52. </el-select>
  53. <!-- <avue-input-tree-->
  54. <!-- v-else-if="item.prop === 'warehouseType'"-->
  55. <!-- leaf-only-->
  56. <!-- placeholder="请选择内容"-->
  57. <!-- :dic="warehouseType"-->
  58. <!-- type="tree"-->
  59. <!-- v-model="form[item.prop]"-->
  60. <!-- style="width: 100%"-->
  61. <!-- size="small"-->
  62. <!-- @change="warehouseTreeChange"-->
  63. <!-- >-->
  64. <!-- </avue-input-tree>-->
  65. <el-select v-else-if="item.prop === 'storageId'" v-model="form[item.prop]" placeholder="请选择" clearable filterable style="width: 100%" size="small">
  66. <el-option v-for="(item,index) in warehouseName" :key="index" :label="item.cname" :value="item.id" size="small"></el-option>
  67. </el-select>
  68. <el-input type="textarea" v-else-if="item.type === 'textarea'" v-model="form[item.prop]" size="small" autocomplete="off" :disabled="item.disabled"></el-input>
  69. <el-input type="age" v-else v-model="form[item.prop]" size="small" autocomplete="off" :disabled="item.disabled"></el-input>
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. </basic-container>
  74. <containerTitle title="商品信息"></containerTitle>
  75. <basic-container style="margin-bottom: 10px">
  76. <avue-crud
  77. :option="customerContact"
  78. v-model="contactsForm"
  79. :data="contactsData"
  80. ref="crudContact"
  81. @row-save="rowSave"
  82. @row-click="handleRowClick"
  83. @row-update="rowUpdate"
  84. @row-del="rowDel"
  85. @saveColumn="saveColumn('goods')"
  86. >
  87. <template slot="code" slot-scope="{row,index}">
  88. <span style="float: left;padding-top: 2px">{{ row.code }}</span>
  89. <el-button type="text" size="mini" style="float: right" @click="commodityChoice(row)">选择</el-button>
  90. </template>
  91. <template slot-scope="{row,index}" slot="menu">
  92. <el-button
  93. type="text"
  94. size="small"
  95. @click="rowCell(row,index)"
  96. >{{ row.$cellEdit ? '保存' : '修改' }}
  97. </el-button>
  98. </template>
  99. <template slot="actualQuantity" slot-scope="{ row }">
  100. <el-input
  101. v-if="row.$cellEdit"
  102. v-model="row.actualQuantity"
  103. v-input-limit="0"
  104. @change="actualQuantityChange(row)"
  105. ></el-input>
  106. <span v-else>{{ row.actualQuantity }}</span>
  107. </template>
  108. <template slot="menuLeft" slot-scope="{size}">
  109. <el-button type="primary"
  110. icon="el-icon-plus"
  111. size="small"
  112. @click="commoditySelection"
  113. >录入明细
  114. </el-button>
  115. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  116. </template>
  117. </avue-crud>
  118. </basic-container>
  119. <containerTitle title="费用明细"></containerTitle>
  120. <basic-container style="margin-bottom: 10px">
  121. <avue-crud
  122. :option="advantageProject"
  123. v-model="advantageProjectForm"
  124. :data="advantageProjectData"
  125. ref="crudProject"
  126. @row-save="rowSaveProject"
  127. @row-update="rowUpdateProject"
  128. @row-del="rowDelProject"
  129. @saveColumn="saveColumn('fees')"
  130. >
  131. <template slot="code" slot-scope="{row,index}">
  132. <span style="float: left;padding-top: 2px">{{ row.code }}</span>
  133. <el-button type="text" size="mini" style="float: right" @click="choice(row)">选择</el-button>
  134. </template>
  135. <template slot="corpId" slot-scope="{ row }">
  136. <selectComponent v-if="row.$cellEdit" v-model="row.corpId"
  137. :configuration="configuration" @receiveList="receiveList"/>
  138. <span v-else>
  139. <span v-for="item in configuration.dicData" v-if="item.id == row.corpId">{{ item.cname }}</span>
  140. </span>
  141. </template>
  142. <template slot-scope="{row,index}" slot="menu">
  143. <el-button
  144. type="text"
  145. size="small"
  146. @click="rowCellTwo(row,index)"
  147. >{{ row.$cellEdit ? '保存' : '修改' }}
  148. </el-button>
  149. </template>
  150. <template slot="menuLeft" slot-scope="{size}">
  151. <el-button type="primary"
  152. icon="el-icon-plus"
  153. size="small"
  154. @click="costIncrease"
  155. >录入明细
  156. </el-button>
  157. </template>
  158. </avue-crud>
  159. </basic-container>
  160. <containerTitle title="附件上传"></containerTitle>
  161. <basic-container style="margin-bottom: 40px">
  162. <avue-crud
  163. :option="bankOfDeposit"
  164. v-model="bankOfDepositForm"
  165. :data="bankOfDepositData"
  166. @row-save="rowSaveBankOfDeposit"
  167. @row-update="rowUpdateBankOfDeposit"
  168. @row-del="rowDelBankOfDeposit"
  169. :upload-after="uploadAfter"
  170. ></avue-crud>
  171. </basic-container>
  172. </el-form>
  173. </div>
  174. <el-dialog
  175. title="导入商品"
  176. append-to-body
  177. class="el-dialogDeep"
  178. :visible.sync="dialogVisible"
  179. width="80%"
  180. :close-on-click-modal="false"
  181. :destroy-on-close="true"
  182. :close-on-press-escape="false"
  183. @close="closeGoods">
  184. <el-row style="height: 0;">
  185. <el-col :span="5">
  186. <div>
  187. <el-scrollbar>
  188. <basic-container>
  189. <avue-tree :option="treeOption" :data="treeDataGoods" @node-click="nodeClick"/>
  190. </basic-container>
  191. </el-scrollbar>
  192. </div>
  193. </el-col>
  194. <el-col :span="19">
  195. <basic-container>
  196. <avue-crud :option="optionTwo"
  197. :table-loading="loading"
  198. :data="data"
  199. ref="crud"
  200. @refresh-change="refreshChange"
  201. @selection-change="selectionChange"
  202. :page.sync="page"
  203. @on-load="onLoad"></avue-crud>
  204. </basic-container>
  205. </el-col>
  206. </el-row>
  207. <span slot="footer" class="dialog-footer">
  208. <el-button @click="dialogVisible = false">取 消</el-button>
  209. <el-button type="primary" @click="importGoods" v-if="commodityData !== true">导入</el-button>
  210. <el-button type="primary" @click="importChoice" v-if="commodityData === true"
  211. :disabled="tableData.length !== 1">导入</el-button>
  212. </span>
  213. </el-dialog>
  214. <el-dialog
  215. title="导入费用"
  216. append-to-body
  217. class="el-dialogDeep"
  218. :visible.sync="dialogCost"
  219. width="80%"
  220. :close-on-click-modal="false"
  221. :destroy-on-close="true"
  222. :close-on-press-escape="false"
  223. @close="closeFees">
  224. <el-row style="height: 0;">
  225. <el-col :span="5">
  226. <div>
  227. <el-scrollbar>
  228. <basic-container>
  229. <avue-tree :option="treeOptionCost" :data="treeData" @node-click="nodeClickCost"/>
  230. </basic-container>
  231. </el-scrollbar>
  232. </div>
  233. </el-col>
  234. <el-col :span="19">
  235. <basic-container>
  236. <avue-crud :option="optionTwoCost"
  237. :table-loading="loadingCost"
  238. :data="dataCost"
  239. ref="crud"
  240. @refresh-change="refreshChangeCost"
  241. @selection-change="selectionChangeCost"
  242. :page.sync="pageCost"
  243. @on-load="onLoadCost">
  244. </avue-crud>
  245. </basic-container>
  246. </el-col>
  247. </el-row>
  248. <span slot="footer" class="dialog-footer">
  249. <el-button @click="dialogCost = false">取 消</el-button>
  250. <el-button type="primary" @click="importCost" v-if="choiceData !== true">导入</el-button>
  251. <el-button type="primary" @click="choiceCost" v-if="choiceData === true"
  252. :disabled="tableDataCost.length !== 1">导入</el-button>
  253. </span>
  254. </el-dialog>
  255. </div>
  256. </template>
  257. <script>
  258. import {
  259. typeSave, detail, deleteDetails,
  260. corpstypeTree,
  261. corpsattn,
  262. corpsbank,
  263. corpsfiles,
  264. corpsitem,
  265. getList,
  266. sendInGoods,
  267. revokeInGoods
  268. } from "@/api/basicData/receipt"
  269. import customerContact from "./configuration/customerContact.json"
  270. import advantageProject from "./configuration/advantageProject.json"
  271. import bankOfDeposit from "./configuration/bankOfDeposit.json"
  272. import commodity from "./configuration/commodity.json"
  273. import optionTwoCost from "./configuration/mainListCost.json"
  274. import {getDeptLazyTree, customerList,getDeptLazyTreeTwo} from "@/api/basicData/basicFeesDesc";
  275. import {customerList as wareHouseType} from "@/api/basicData/basicStorageType"
  276. import {customerList as selectWareHouse} from "@/api/basicData/basicStorageDesc"
  277. import {selectGoodsNum} from "@/api/basicData/inventoryAccount"
  278. import { contrastObj, contrastList } from "@/util/contrastData";
  279. export default {
  280. name: "detailsPage",
  281. props: {
  282. detailData: {
  283. type: Object
  284. }
  285. },
  286. data() {
  287. return {
  288. configuration: {
  289. multipleChoices: false,
  290. multiple: false,
  291. collapseTags: false,
  292. placeholder: '请点击右边按钮选择',
  293. dicData: []
  294. },
  295. form: {},
  296. data: [],
  297. loadingCost: false,
  298. choiceData: false,
  299. commodityData: false,
  300. dataCost: [],
  301. choiceIndex: '',
  302. dialogCost: false,
  303. treeDeptId: '',
  304. treeDeptIdCost: '',
  305. pageCost: {
  306. pageSize: 10,
  307. currentPage: 1,
  308. total: 0
  309. },
  310. page: {
  311. pageSize: 10,
  312. currentPage: 1,
  313. total: 0
  314. },
  315. loading: false,
  316. contactsForm: {},
  317. optionTwo: commodity,
  318. optionTwoCost: optionTwoCost,
  319. treeData: [],
  320. treeDataGoods: [],
  321. treeOptionCost: {
  322. nodeKey: 'id',
  323. lazy: true,
  324. treeLoad: function (node, resolve) {
  325. const parentId = (node.level === 0) ? 0 : node.data.id;
  326. getDeptLazyTree(parentId).then(res => {
  327. resolve(res.data.data.map(item => {
  328. return {
  329. ...item,
  330. leaf: !item.hasChildren
  331. }
  332. }))
  333. });
  334. },
  335. addBtn: false,
  336. menu: false,
  337. size: 'small',
  338. props: {
  339. labelText: '标题',
  340. label: 'title',
  341. value: 'value',
  342. children: 'children'
  343. }
  344. },
  345. treeOption: {
  346. nodeKey: 'id',
  347. lazy: true,
  348. treeLoad: function (node, resolve) {
  349. const parentId = (node.level === 0) ? 0 : node.data.id;
  350. getDeptLazyTreeTwo(parentId).then(res => {
  351. resolve(res.data.data.map(item => {
  352. return {
  353. ...item,
  354. leaf: !item.hasChildren
  355. }
  356. }))
  357. });
  358. },
  359. addBtn: false,
  360. menu: false,
  361. size: 'small',
  362. props: {
  363. labelText: '标题',
  364. label: 'title',
  365. value: 'value',
  366. children: 'children'
  367. }
  368. },
  369. dialogVisible: false,
  370. advantageProjectForm: {},
  371. bankOfDepositForm: {},
  372. contactsData: [],
  373. advantageProjectData: [],
  374. disabled: false,
  375. bankOfDepositData: [],
  376. tableDataCost: [],
  377. dic: [],
  378. tableData: [],
  379. customerContact: {},
  380. advantageProject: {},
  381. bankOfDeposit: bankOfDeposit,
  382. basicData: {
  383. column: [
  384. {
  385. label: '系统编号',//发货通知(点击)
  386. prop: 'sysNo',
  387. disabled: true,
  388. rules: [
  389. {
  390. required: false,
  391. message: ' ',
  392. trigger: 'blur'
  393. }
  394. ]
  395. }, {
  396. label: '采购方式',
  397. prop: 'purchaseMode',
  398. rules: [
  399. {
  400. required: true,
  401. message: ' ',
  402. trigger: 'blur'
  403. }
  404. ]
  405. }, {
  406. label: '供应商',
  407. prop: 'corpId',
  408. rules: [
  409. {
  410. required: true,
  411. message: ' ',
  412. trigger: 'blur'
  413. }
  414. ]
  415. }, {
  416. label: '所属公司',
  417. prop: 'salesCompany',
  418. rules: [
  419. {
  420. required: true,
  421. message: ' ',
  422. trigger: 'blur'
  423. }
  424. ]
  425. },{
  426. label: '仓库类型',
  427. prop: 'warehouseType',//字典表
  428. rules: [
  429. {
  430. required: true,
  431. message: ' ',
  432. trigger: 'blur'
  433. }
  434. ]
  435. }, {
  436. label: '仓库名称',
  437. prop: 'storageId',
  438. rules: [
  439. {
  440. required: true,
  441. message: ' ',
  442. trigger: 'blur'
  443. }
  444. ]
  445. }, {
  446. label: '匹配订单号',
  447. prop: 'srcOrderNo',
  448. rules: [
  449. {
  450. required: true,
  451. message: ' ',
  452. trigger: 'blur'
  453. }
  454. ]
  455. },{
  456. label: '入库金额',
  457. prop: 'deliveryAmount',
  458. disabled: true,
  459. rules: [
  460. {
  461. required: true,
  462. message: ' ',
  463. trigger: 'blur'
  464. }
  465. ]
  466. }, {
  467. label: '采购金额',
  468. prop: 'purchaseAmount',
  469. disabled: true,
  470. rules: [
  471. {
  472. required: true,
  473. message: ' ',
  474. trigger: 'blur'
  475. }
  476. ]
  477. },{
  478. label: '入库数量',
  479. prop: 'totalQuantity',
  480. disabled: true,
  481. rules: [
  482. {
  483. required: true,
  484. message: ' ',
  485. trigger: 'blur'
  486. }
  487. ]
  488. }, {
  489. label: '费用合计',
  490. prop: 'totalCost',
  491. rules: [
  492. {
  493. required: false,
  494. message: ' ',
  495. trigger: 'blur'
  496. }
  497. ]
  498. }, {
  499. label: '入库日期',
  500. prop: 'businessDate',
  501. type: 'datetime',
  502. rules: [
  503. {
  504. required: true,
  505. message: ' ',
  506. trigger: 'blur'
  507. }
  508. ]
  509. }, {
  510. label: "入库单备注",
  511. span: 24,
  512. type: 'textarea',
  513. prop: "deliveryRemarks",
  514. mock: {
  515. type: 'county'
  516. }
  517. }
  518. ]
  519. },
  520. statusOption: [],
  521. procurementMethodOption: [],
  522. // 仓库类型
  523. warehouseType: [],
  524. // 仓库名称
  525. warehouseName: [],
  526. // 第一次进入
  527. firstComing: false,
  528. // 费用信息排序的最大值
  529. maxFeeNum: 0,
  530. maxGoodsNum: 0,
  531. oldForm: {
  532. orderStatus: "录入"
  533. },
  534. oldGoodsList: [],
  535. oldFeesList: [],
  536. oldUploadList: [],
  537. }
  538. },
  539. //初始化查询
  540. async created() {
  541. this.customerContact = await this.getColumnData(this.getColumnName(24), customerContact);
  542. this.advantageProject = await this.getColumnData(this.getColumnName(25), advantageProject);
  543. this.getWorkDicts("procurement_method").then(res => {
  544. this.procurementMethodOption = res.data.data
  545. })
  546. wareHouseType().then(res => {
  547. this.warehouseType = res.data.data.records
  548. this.warehouseType.forEach(item => {
  549. this.$set(item, 'label', item.cname)
  550. this.$set(item, 'value', item.id)
  551. if (item.hasChildren) {
  552. this.$set(item, 'children', [])
  553. }
  554. })
  555. let result = [], temp = {}
  556. for(let i = 0; i < this.warehouseType.length;i++) {
  557. temp[this.warehouseType[i].id] = this.warehouseType[i]
  558. }
  559. for (let j = 0;j < this.warehouseType.length;j++) {
  560. let current = this.warehouseType[j]
  561. let tempCurrentParent = temp[current.parentId]
  562. if (tempCurrentParent) {
  563. if (!tempCurrentParent["children"]) {
  564. tempCurrentParent["children"] = []
  565. }
  566. tempCurrentParent["children"].push(current)
  567. } else {
  568. result.push(current)
  569. }
  570. }
  571. this.warehouseType = result
  572. });
  573. selectWareHouse().then(res => {
  574. this.warehouseName = res.data.data.records
  575. })
  576. if (this.detailData.id) {
  577. this.queryData(this.detailData.id)
  578. }else if (this.detailData.form){
  579. this.form = JSON.parse(this.detailData.form);
  580. delete this.form.createTime
  581. delete this.form.id
  582. delete this.form.sysNo
  583. this.contactsData = this.form.orderItemsList
  584. delete this.form.orderItemsList
  585. this.configuration.dicData = this.form.corpName
  586. delete this.form.corpName
  587. this.$set(this.form, 'deliveryStatus', '录入')
  588. if (this.form.belongToCorpList) {
  589. this.$set(this.form, 'salesCompany', this.form.belongToCorpId)
  590. delete this.form.belongToCorpId
  591. this.configuration.dicData = this.configuration.dicData.concat(this.form.belongToCorpList)
  592. }
  593. delete this.form.belongToCorpList
  594. this.$set(this.form, 'deliveryAmount', 0)
  595. this.$set(this.form, 'totalQuantity', 0)
  596. this.$set(this.form, 'purchaseAmount', 0)
  597. this.contactsData.forEach(item => {
  598. this.$set(item, 'orgOrderNo', this.form.orgOrderNo)
  599. this.$set(item, "inventoryNumber", item.storageQuantity)
  600. this.$set(item, "srcId", item.id)
  601. this.$set(item, "deliveryAmount", item.amount)
  602. this.$set(item, "actualQuantity", (Number(item.purchaseQuantity) - Number(item.actualQuantity)))
  603. // 入库数量和入库金额的比例
  604. this.$set(item, 'scale', (item.deliveryAmount / item.actualQuantity))
  605. this.form.deliveryAmount += Number(item.deliveryAmount)
  606. this.form.totalQuantity += Number(item.actualQuantity)
  607. this.form.purchaseAmount += Number(item.deliveryAmount)
  608. this.form.deliveryAmount = (this.form.deliveryAmount).toFixed(2)
  609. this.form.purchaseAmount = (this.form.purchaseAmount).toFixed(2)
  610. delete item.id
  611. delete item.pid
  612. })
  613. } else if (this.detailData.copyId) {
  614. this.queryData(this.detailData.copyId, true)
  615. }
  616. },
  617. watch: {
  618. },
  619. methods: {
  620. queryData(id, isCopy = false) {
  621. detail(id).then(res => {
  622. console.log(res.data.data)
  623. this.form = res.data.data;
  624. this.contactsData = this.form.deliveryItemsList
  625. this.advantageProjectData = this.form.deliveryFeesList
  626. this.bankOfDepositData = this.form.deliveryFilesList
  627. this.configuration.dicData = this.form.corpName
  628. this.contactsData.forEach(item => {
  629. // this.form.deliveryAmount += Number(item.deliveryAmount)
  630. // this.form.totalQuantity += Number(item.actualQuantity)
  631. // 入库金额和入库数量的比例
  632. this.$set(item, 'scale', (item.deliveryAmount / item.actualQuantity))
  633. })
  634. let feesData = []
  635. this.form.deliveryFeesList.forEach(item => {
  636. let a = {
  637. cname: item.corpName,
  638. id: item.corpId
  639. }
  640. feesData.push(a)
  641. })
  642. this.configuration.dicData = this.configuration.dicData.concat(feesData)
  643. // 去重
  644. this.removeRepeat()
  645. if (this.form.companyName) {
  646. this.configuration.dicData = this.configuration.dicData.concat(this.form.companyName)
  647. }
  648. delete this.form.deliveryItemsList
  649. delete this.form.deliveryFeesList
  650. delete this.form.deliveryFilesList
  651. delete this.form.corpName
  652. delete this.form.companyName
  653. // 获取最大值
  654. let num = []
  655. this.advantageProjectData.forEach(item => {
  656. num.push(item.sort)
  657. })
  658. if (num.length == 0) {
  659. this.maxFeeNum = 0;
  660. } else {
  661. this.maxFeeNum = num.reduce((a, b) => {
  662. return b > a? b: a;
  663. })
  664. }
  665. let goodsNum = []
  666. this.contactsData.forEach(item => {
  667. goodsNum.push(item.sort)
  668. })
  669. if (goodsNum.length == 0) {
  670. this.maxGoodsNum = 0;
  671. } else {
  672. this.maxGoodsNum = goodsNum.reduce((a, b) => {
  673. return b > a? b: a;
  674. })
  675. }
  676. this.oldGoodsList = []
  677. this.oldFeesList = []
  678. this.oldUploadList = []
  679. this.oldForm = Object.assign({}, this.form)
  680. this.oldGoodsList = this.oldGoodsList.concat(this.contactsData)
  681. this.oldFeesList = this.oldFeesList.concat(this.advantageProjectData)
  682. this.oldUploadList = this.oldUploadList.concat(this.bankOfDepositData)
  683. if (isCopy) {
  684. delete this.form.id
  685. delete this.form.sysNo
  686. this.contactsData.forEach(item => {
  687. delete item.id
  688. delete item.pid
  689. })
  690. this.advantageProjectData.forEach(item => {
  691. delete item.id
  692. delete item.pid
  693. })
  694. this.bankOfDepositData.forEach(item => {
  695. delete item.id
  696. delete item.pid
  697. })
  698. form.deliveryStatus == '录入'
  699. }
  700. });
  701. },
  702. copyOrder() {
  703. this.queryData(this.form.id, true)
  704. },
  705. // 入库数量变化时调用
  706. actualQuantityChange(row) {
  707. if (row.scale) {
  708. row.deliveryAmount = Number(row.actualQuantity) * Number(row.scale)
  709. }
  710. },
  711. // 类别变换时触发
  712. warehouseTreeChange(id) {
  713. this.warehouseName = []
  714. if (this.firstComing) {
  715. if (!this.form.storageId) {
  716. this.$set(this.form, 'storageId', null)
  717. } else {
  718. this.form.storageId = null
  719. }
  720. }
  721. let data = {
  722. storageTypeId: id
  723. }
  724. selectWareHouse(data).then(res => {
  725. this.warehouseName = res.data.data.records
  726. })
  727. this.firstComing = true
  728. },
  729. //点击行可编辑
  730. handleRowClick(row, event, column) {
  731. console.log(row.$index)
  732. },
  733. //商品编辑
  734. rowCell(row, index) {
  735. console.log(row)
  736. this.$refs.crudContact.rowCell(row, index)
  737. },
  738. //费用编辑
  739. rowCellTwo(row, index) {
  740. console.log(row)
  741. this.$refs.crudProject.rowCell(row, index)
  742. },
  743. //费用新增触发
  744. costIncrease() {
  745. this.dialogCost = !this.dialogCost
  746. this.choiceData = false
  747. },
  748. //商品新增触发
  749. commoditySelection() {
  750. this.dialogVisible = !this.dialogVisible
  751. this.tableData = []
  752. this.commodityData = false
  753. },
  754. //点击费用明细选择触发
  755. choice(row) {
  756. this.dialogCost = !this.dialogCost
  757. this.choiceData = true
  758. console.log(row)
  759. this.choiceIndex = row.$index
  760. },
  761. //点击商品明细选择触发
  762. commodityChoice(row) {
  763. this.dialogVisible = !this.dialogVisible
  764. this.commodityData = true
  765. console.log(row)
  766. this.choiceIndexT = row.$index
  767. },
  768. //导入商品触发
  769. importChoice() {
  770. if (this.tableData.length === 1) {
  771. this.contactsData[this.choiceIndexT].cname = this.tableData[0].cname
  772. this.contactsData[this.choiceIndexT].code = this.tableData[0].code
  773. this.contactsData[this.choiceIndexT].typeno = this.tableData[0].typeno
  774. this.contactsData[this.choiceIndexT].specificationAndModel = this.tableData[0].specificationAndModel
  775. this.contactsData[this.choiceIndexT].itemId = this.tableData[0].id
  776. selectGoodsNum({
  777. goodsId: this.tableData[0].id,
  778. typeno: this.tableData[0].typeno
  779. }).then(res => {
  780. this.contactsData[this.choiceIndexT].storageQuantity = res.data.data
  781. })
  782. }
  783. this.dialogVisible = !this.dialogVisible
  784. this.commodityData = false
  785. },
  786. //费用编辑导入触发
  787. choiceCost() {
  788. console.log('1111')
  789. if (this.tableDataCost.length === 1) {
  790. this.advantageProjectData[this.choiceIndex].feeName = this.tableDataCost[0].cname
  791. this.advantageProjectData[this.choiceIndex].itemId = this.tableDataCost[0].id
  792. this.advantageProjectData[this.choiceIndex].code = this.tableDataCost[0].code
  793. }
  794. this.dialogCost = !this.dialogCost
  795. this.choiceData = false
  796. },
  797. //费用导入触发
  798. importCost() {
  799. console.log('111111')
  800. // this.advantageProjectForm = this.advantageProjectForm.concat(this.tableDataCost)
  801. if (this.tableDataCost.length > 0) {
  802. for (let item in this.tableDataCost) {
  803. console.log(this.tableDataCost[item])
  804. this.tableDataCost[item].itemId = this.tableDataCost[item].id
  805. this.tableDataCost[item].feeName = this.tableDataCost[item].cname
  806. this.tableDataCost[item].sort = this.maxFeeNum + 1
  807. this.maxFeeNum++
  808. delete this.tableDataCost[item].id
  809. this.$refs.crudProject.rowCellAdd(this.tableDataCost[item]);
  810. this.$refs.crudProject.rowCell(this.tableDataCost[item], this.advantageProjectForm.length - 1)
  811. }
  812. }
  813. this.tableDataCost = []
  814. this.dialogCost = false
  815. },
  816. //确认导入触发
  817. importGoods() {
  818. // this.contactsData = this.contactsData.concat(this.tableData)
  819. if (this.tableData.length > 0) {
  820. for (let item in this.tableData) {
  821. selectGoodsNum({
  822. goodsId: this.tableData[item].id,
  823. typeno: this.tableData[item].typeno
  824. }).then(res => {
  825. this.tableData[item].storageQuantity = res.data.data
  826. this.tableData[item].itemId = this.tableData[item].id
  827. this.tableData[item].priceCategory = this.tableData[item].goodsTypeName
  828. delete this.tableData[item].goodsTypeName
  829. delete this.tableData[item].id
  830. delete this.tableData[item].status
  831. delete this.tableData[item].isDeleted
  832. this.$set(this.tableData[item], 'specificationAndModel', this.tableData[item].specificationAndModel)
  833. this.$set(this.tableData[item], 'purchaseQuantity', 0)
  834. this.$set(this.tableData[item], 'actualQuantity', 0)
  835. this.$set(this.tableData[item], 'purchaseAmount', 0)
  836. this.$set(this.tableData[item], 'deliveryAmount', 0)
  837. this.tableData[item].sort = this.maxGoodsNum + 1
  838. this.maxGoodsNum++
  839. this.$refs.crudContact.rowCellAdd(this.tableData[item]);
  840. this.$refs.crudContact.rowCell(this.tableData[item], this.contactsData.length - 1)
  841. })
  842. }
  843. }
  844. this.dialogVisible = false
  845. },
  846. closeGoods() {
  847. this.treeDataGoods = [];
  848. this.treeDeptId = "";
  849. },
  850. closeFees() {
  851. this.treeDeptIdCost = "";
  852. this.treeData = [];
  853. },
  854. //选中触发
  855. selectionChange(list) {
  856. console.log(list);
  857. this.tableData = list
  858. },
  859. //费用选中触发
  860. selectionChangeCost(list) {
  861. console.log(list);
  862. this.tableDataCost = list
  863. },
  864. //导入页左商品类型查询
  865. nodeClick(data) {
  866. this.treeDeptId = data.id;
  867. this.page.currentPage = 1;
  868. this.onLoad(this.page);
  869. },
  870. //导入页左费用类型查询
  871. nodeClickCost(data) {
  872. this.treeDeptIdCost = data.id;
  873. this.pageCost.currentPage = 1;
  874. this.onLoadCost(this.pageCost);
  875. },
  876. //刷新触发
  877. refreshChange() {
  878. this.treeDeptId = '';
  879. this.page.currentPage = 1;
  880. this.onLoad(this.page);
  881. },
  882. //费用刷新触发
  883. refreshChangeCost() {
  884. this.treeDeptIdCost = '';
  885. this.pageCost.currentPage = 1;
  886. this.onLoadCost(this.pageCost);
  887. },
  888. //新增商品信息保存触发
  889. rowSave(row, done, loading) {
  890. console.log(row)
  891. console.log(this.contactsData)
  892. // this.contactsData.push(row)
  893. done()
  894. },
  895. //修改商品信息触发
  896. rowUpdate(row, index, done, loading) {
  897. done(row);
  898. },
  899. //删除商品信息触发
  900. rowDel(row, index, donerowDel) {
  901. this.$confirm("确定将选择数据删除?", {
  902. confirmButtonText: "确定",
  903. cancelButtonText: "取消",
  904. type: "warning"
  905. }).then(() => {
  906. //商品判断是否需要调用删除接口
  907. if (row.id) {
  908. corpsattn(row.id).then(res => {
  909. this.$message({
  910. type: "success",
  911. message: "操作成功!"
  912. });
  913. this.contactsData.splice(index, 1);
  914. })
  915. } else {
  916. this.$message({
  917. type: "success",
  918. message: "操作成功!"
  919. });
  920. this.contactsData.splice(index, 1);
  921. }
  922. })
  923. },
  924. //新增费用明细保存触发
  925. rowSaveProject(row, done, loading) {
  926. // this.advantageProjectData.push(row)
  927. done()
  928. },
  929. //修改费用明细触发
  930. rowUpdateProject(row, index, done, loading) {
  931. done(row);
  932. },
  933. //商品列表查询
  934. onLoad(page, params = {}) {
  935. this.loading = true;
  936. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  937. console.log(res)
  938. const data = res.data.data;
  939. this.page.total = data.total;
  940. this.data = data.records;
  941. this.loading = false;
  942. });
  943. },
  944. //费用查询
  945. onLoadCost(page, params = {}) {
  946. this.loadingCost = true;
  947. let queryParams = Object.assign({}, params, {
  948. pageSize: page.pageSize,
  949. pageNum: page.currentPage,
  950. parentId: 0,
  951. feesTypeId: this.treeDeptIdCost
  952. })
  953. customerList(queryParams).then(res => {
  954. console.log(res)
  955. const data = res.data.data;
  956. this.pageCost.total = data.total;
  957. this.dataCost = data.records;
  958. this.loadingCost = false;
  959. });
  960. },
  961. //删除费用明细触发
  962. rowDelProject(row, index, donerowDel) {
  963. this.$confirm("确定将选择数据删除?", {
  964. confirmButtonText: "确定",
  965. cancelButtonText: "取消",
  966. type: "warning"
  967. }).then(() => {
  968. //费用判断是否需要调用删除接口
  969. if (row.id) {
  970. corpsitem(row.id).then(res => {
  971. this.$message({
  972. type: "success",
  973. message: "操作成功!"
  974. });
  975. this.advantageProjectData.splice(index, 1);
  976. })
  977. } else {
  978. this.$message({
  979. type: "success",
  980. message: "操作成功!"
  981. });
  982. this.advantageProjectData.splice(index, 1);
  983. }
  984. })
  985. },
  986. //新增附件上传保存触发
  987. rowSaveBankOfDeposit(row, done, loading) {
  988. this.bankOfDepositData.push(row)
  989. done()
  990. },
  991. //修改附件上传触发
  992. rowUpdateBankOfDeposit(row, index, done, loading) {
  993. done(row);
  994. },
  995. //删除附件上传触发
  996. rowDelBankOfDeposit(row, index, donerowDel) {
  997. this.$confirm("确定将选择数据删除?", {
  998. confirmButtonText: "确定",
  999. cancelButtonText: "取消",
  1000. type: "warning"
  1001. }).then(() => {
  1002. //附件判断是否需要调用删除接口
  1003. if (row.id) {
  1004. corpsbank(row.id).then(res => {
  1005. this.$message({
  1006. type: "success",
  1007. message: "操作成功!"
  1008. });
  1009. this.bankOfDepositData.splice(index, 1);
  1010. })
  1011. } else {
  1012. this.$message({
  1013. type: "success",
  1014. message: "操作成功!"
  1015. });
  1016. this.bankOfDepositData.splice(index, 1);
  1017. }
  1018. })
  1019. },
  1020. uploadAfter(res, done) {
  1021. if (res.originalName) {
  1022. this.bankOfDepositForm.fileName = this.bankOfDepositForm.fileName
  1023. ? this.bankOfDepositForm.fileName
  1024. : res.originalName;
  1025. }
  1026. done();
  1027. },
  1028. // 去重
  1029. removeRepeat() {
  1030. let obj = []
  1031. this.configuration.dicData = this.configuration.dicData.reduce((current,next) => {
  1032. obj[next.id] ? '': obj[next.id] = true && current.push(next)
  1033. return current
  1034. }, [])
  1035. },
  1036. receiveList(data){
  1037. this.configuration.dicData = this.configuration.dicData.concat(data)
  1038. this.removeRepeat()
  1039. },
  1040. // 确认收货
  1041. sendInGoods() {
  1042. this.$refs["form"].validate((valid) => {
  1043. if (valid) {
  1044. if (this.contactsData.length == 0) {
  1045. return this.$message.error('商品信息为空')
  1046. }
  1047. for (let item in this.contactsData) {
  1048. if (!this.contactsData[item].id) {
  1049. return this.$message.error('有商品未保存,请先保存')
  1050. }
  1051. }
  1052. //商品信息
  1053. this.form.deliveryItemsList = this.contactsData
  1054. this.form.deliveryFeesList = this.advantageProjectData
  1055. this.form.deliveryFilesList = this.bankOfDepositData
  1056. if (typeof this.form.corpsTypeId == 'object') {
  1057. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1058. }
  1059. sendInGoods(this.form).then(res => {
  1060. console.log(res)
  1061. this.$message.success('收货成功')
  1062. this.queryData(res.data.data.id)
  1063. })
  1064. } else {
  1065. return false;
  1066. }
  1067. });
  1068. },
  1069. // 撤销收货
  1070. revokeInGoods() {
  1071. this.$refs["form"].validate((valid) => {
  1072. if (valid) {
  1073. //商品信息
  1074. this.form.deliveryItemsList = this.contactsData
  1075. this.form.deliveryFeesList = this.advantageProjectData
  1076. this.form.deliveryFilesList = this.bankOfDepositData
  1077. if (typeof this.form.corpsTypeId == 'object') {
  1078. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1079. }
  1080. revokeInGoods(this.form).then(res => {
  1081. this.$message.success('撤销成功')
  1082. this.queryData(res.data.data.id)
  1083. })
  1084. } else {
  1085. return false;
  1086. }
  1087. });
  1088. },
  1089. //修改提交触发
  1090. editCustomer(isBack = false) {
  1091. console.log(this.form)
  1092. this.$refs["form"].validate((valid) => {
  1093. if (valid) {
  1094. this.form.deliveryAmount = 0
  1095. this.form.totalQuantity = 0
  1096. this.form.purchaseAmount = 0
  1097. this.contactsData.forEach(item => {
  1098. this.form.deliveryAmount += Number(item.deliveryAmount)
  1099. this.form.totalQuantity += Number(item.actualQuantity)
  1100. this.form.purchaseAmount += Number(item.deliveryAmount)
  1101. this.form.deliveryAmount = (this.form.deliveryAmount).toFixed(2)
  1102. this.form.purchaseAmount = (this.form.purchaseAmount).toFixed(2)
  1103. })
  1104. //商品信息
  1105. this.form.deliveryItemsList = this.contactsData
  1106. this.form.deliveryFeesList = this.advantageProjectData
  1107. this.form.deliveryFilesList = this.bankOfDepositData
  1108. if (typeof this.form.corpsTypeId == 'object') {
  1109. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1110. }
  1111. this.disabled = true
  1112. typeSave(this.form).then(res => {
  1113. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  1114. this.disabled = false
  1115. if (isBack) {
  1116. //成功关闭此页面回到列表页
  1117. this.$emit("goBack");
  1118. } else {
  1119. this.queryData(res.data.data.id)
  1120. }
  1121. })
  1122. } else {
  1123. return false;
  1124. }
  1125. });
  1126. },
  1127. //返回列表
  1128. backToList() {
  1129. if (contrastObj(this.form, this.oldForm) ||
  1130. contrastList(this.contactsData, this.oldGoodsList) ||
  1131. contrastList(this.advantageProjectData, this.oldFeesList) ||
  1132. contrastList(this.bankOfDepositData, this.oldUploadList)
  1133. ) {
  1134. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  1135. confirmButtonText: "确定",
  1136. cancelButtonText: "取消",
  1137. type: "warning"
  1138. }).then(() => {
  1139. this.editCustomer(true)
  1140. }).catch(() => {
  1141. this.$emit("goBack");
  1142. })
  1143. } else {
  1144. this.$emit("goBack");
  1145. }
  1146. },
  1147. // 保存列设置
  1148. async saveColumn(name) {
  1149. /**
  1150. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  1151. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  1152. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  1153. */
  1154. if (name == 'goods') {
  1155. const inSave = await this.saveColumnData(
  1156. this.getColumnName(24),
  1157. this.customerContact
  1158. );
  1159. if (inSave) {
  1160. this.$message.success("保存成功");
  1161. //关闭窗口
  1162. this.$refs.crudContact.$refs.dialogColumn.columnBox = false;
  1163. }
  1164. } else if (name === 'fees') {
  1165. const inSave = await this.saveColumnData(
  1166. this.getColumnName(25),
  1167. this.advantageProject
  1168. );
  1169. if (inSave) {
  1170. this.$message.success("保存成功");
  1171. //关闭窗口
  1172. this.$refs.crudProject.$refs.dialogColumn.columnBox = false;
  1173. }
  1174. }
  1175. },
  1176. }
  1177. }
  1178. </script>
  1179. <style lang="scss" scoped>
  1180. .customer-head {
  1181. position: fixed;
  1182. top: 105px;
  1183. width: 100%;
  1184. margin-left: -10px;
  1185. height: 62px;
  1186. background: #ffffff;
  1187. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  1188. z-index: 999;
  1189. /* display: flex;
  1190. justify-content: left; */
  1191. }
  1192. .customer-back {
  1193. cursor: pointer;
  1194. line-height: 62px;
  1195. font-size: 16px;
  1196. color: #323233;
  1197. font-weight: 400;
  1198. }
  1199. .back-icon {
  1200. line-height: 64px;
  1201. font-size: 20px;
  1202. margin-right: 8px;
  1203. }
  1204. .add-customer-btn {
  1205. position: fixed;
  1206. right: 36px;
  1207. top: 115px;
  1208. }
  1209. ::v-deep .el-form-item {
  1210. margin-bottom: 0;
  1211. }
  1212. .el-dialogDeep {
  1213. ::v-deep .el-dialog {
  1214. margin: 1vh auto 0 !important;
  1215. padding-bottom: 10px !important;
  1216. .el-dialog__body, .el-dialog__footer {
  1217. padding-bottom: 0 !important;
  1218. padding-top: 0 !important;
  1219. }
  1220. }
  1221. }
  1222. .print-div {
  1223. color: #000;
  1224. }
  1225. .print_table {
  1226. table {
  1227. border-right: 1px solid #000;
  1228. border-bottom: 1px solid #000;
  1229. font-size: 12px;
  1230. margin-bottom: 5px;
  1231. }
  1232. table td {
  1233. border-left: 1px solid #000;
  1234. border-top: 1px solid #000;
  1235. vertical-align: middle;
  1236. padding: 2px;
  1237. text-align: center;
  1238. }
  1239. }
  1240. .table {
  1241. border-collapse: collapse;
  1242. border-spacing: 0;
  1243. background-color: transparent;
  1244. display: table;
  1245. width: 99%;
  1246. max-width: 100%;
  1247. margin: 0 auto;
  1248. }
  1249. .table td {
  1250. text-align: left;
  1251. vertical-align: middle;
  1252. font-size: 14px;
  1253. color: #000000;
  1254. padding: 10.5px 0 10.5px 30px;
  1255. //border: 1px solid #000;
  1256. }
  1257. </style>