detailsPageEdit.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  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. export default {
  279. name: "detailsPage",
  280. props: {
  281. detailData: {
  282. type: Object
  283. }
  284. },
  285. data() {
  286. return {
  287. configuration: {
  288. multipleChoices: false,
  289. multiple: false,
  290. collapseTags: false,
  291. placeholder: '请点击右边按钮选择',
  292. dicData: []
  293. },
  294. form: {},
  295. data: [],
  296. loadingCost: false,
  297. choiceData: false,
  298. commodityData: false,
  299. dataCost: [],
  300. choiceIndex: '',
  301. dialogCost: false,
  302. treeDeptId: '',
  303. treeDeptIdCost: '',
  304. pageCost: {
  305. pageSize: 10,
  306. currentPage: 1,
  307. total: 0
  308. },
  309. page: {
  310. pageSize: 10,
  311. currentPage: 1,
  312. total: 0
  313. },
  314. loading: false,
  315. contactsForm: {},
  316. optionTwo: commodity,
  317. optionTwoCost: optionTwoCost,
  318. treeData: [],
  319. treeDataGoods: [],
  320. treeOptionCost: {
  321. nodeKey: 'id',
  322. lazy: true,
  323. treeLoad: function (node, resolve) {
  324. const parentId = (node.level === 0) ? 0 : node.data.id;
  325. getDeptLazyTree(parentId).then(res => {
  326. resolve(res.data.data.map(item => {
  327. return {
  328. ...item,
  329. leaf: !item.hasChildren
  330. }
  331. }))
  332. });
  333. },
  334. addBtn: false,
  335. menu: false,
  336. size: 'small',
  337. props: {
  338. labelText: '标题',
  339. label: 'title',
  340. value: 'value',
  341. children: 'children'
  342. }
  343. },
  344. treeOption: {
  345. nodeKey: 'id',
  346. lazy: true,
  347. treeLoad: function (node, resolve) {
  348. const parentId = (node.level === 0) ? 0 : node.data.id;
  349. getDeptLazyTreeTwo(parentId).then(res => {
  350. resolve(res.data.data.map(item => {
  351. return {
  352. ...item,
  353. leaf: !item.hasChildren
  354. }
  355. }))
  356. });
  357. },
  358. addBtn: false,
  359. menu: false,
  360. size: 'small',
  361. props: {
  362. labelText: '标题',
  363. label: 'title',
  364. value: 'value',
  365. children: 'children'
  366. }
  367. },
  368. dialogVisible: false,
  369. advantageProjectForm: {},
  370. bankOfDepositForm: {},
  371. contactsData: [],
  372. advantageProjectData: [],
  373. disabled: false,
  374. bankOfDepositData: [],
  375. tableDataCost: [],
  376. dic: [],
  377. tableData: [],
  378. customerContact: {},
  379. advantageProject: {},
  380. bankOfDeposit: bankOfDeposit,
  381. basicData: {
  382. column: [
  383. {
  384. label: '系统编号',//发货通知(点击)
  385. prop: 'sysNo',
  386. disabled: true,
  387. rules: [
  388. {
  389. required: false,
  390. message: ' ',
  391. trigger: 'blur'
  392. }
  393. ]
  394. }, {
  395. label: '采购方式',
  396. prop: 'purchaseMode',
  397. rules: [
  398. {
  399. required: true,
  400. message: ' ',
  401. trigger: 'blur'
  402. }
  403. ]
  404. }, {
  405. label: '供应商',
  406. prop: 'corpId',
  407. rules: [
  408. {
  409. required: true,
  410. message: ' ',
  411. trigger: 'blur'
  412. }
  413. ]
  414. }, {
  415. label: '所属公司',
  416. prop: 'salesCompany',
  417. rules: [
  418. {
  419. required: true,
  420. message: ' ',
  421. trigger: 'blur'
  422. }
  423. ]
  424. },{
  425. label: '仓库类型',
  426. prop: 'warehouseType',//字典表
  427. rules: [
  428. {
  429. required: true,
  430. message: ' ',
  431. trigger: 'blur'
  432. }
  433. ]
  434. }, {
  435. label: '仓库名称',
  436. prop: 'storageId',
  437. rules: [
  438. {
  439. required: true,
  440. message: ' ',
  441. trigger: 'blur'
  442. }
  443. ]
  444. }, {
  445. label: '匹配订单号',
  446. prop: 'srcOrderNo',
  447. rules: [
  448. {
  449. required: true,
  450. message: ' ',
  451. trigger: 'blur'
  452. }
  453. ]
  454. },{
  455. label: '入库金额',
  456. prop: 'deliveryAmount',
  457. disabled: true,
  458. rules: [
  459. {
  460. required: true,
  461. message: ' ',
  462. trigger: 'blur'
  463. }
  464. ]
  465. }, {
  466. label: '采购金额',
  467. prop: 'purchaseAmount',
  468. disabled: true,
  469. rules: [
  470. {
  471. required: true,
  472. message: ' ',
  473. trigger: 'blur'
  474. }
  475. ]
  476. },{
  477. label: '入库数量',
  478. prop: 'totalQuantity',
  479. disabled: true,
  480. rules: [
  481. {
  482. required: true,
  483. message: ' ',
  484. trigger: 'blur'
  485. }
  486. ]
  487. }, {
  488. label: '费用合计',
  489. prop: 'totalCost',
  490. rules: [
  491. {
  492. required: false,
  493. message: ' ',
  494. trigger: 'blur'
  495. }
  496. ]
  497. }, {
  498. label: '入库日期',
  499. prop: 'businessDate',
  500. type: 'datetime',
  501. rules: [
  502. {
  503. required: true,
  504. message: ' ',
  505. trigger: 'blur'
  506. }
  507. ]
  508. }, {
  509. label: "入库单备注",
  510. span: 24,
  511. type: 'textarea',
  512. prop: "deliveryRemarks",
  513. mock: {
  514. type: 'county'
  515. }
  516. }
  517. ]
  518. },
  519. statusOption: [],
  520. procurementMethodOption: [],
  521. // 仓库类型
  522. warehouseType: [],
  523. // 仓库名称
  524. warehouseName: [],
  525. // 第一次进入
  526. firstComing: false,
  527. // 费用信息排序的最大值
  528. maxFeeNum: 0,
  529. maxGoodsNum: 0,
  530. }
  531. },
  532. //初始化查询
  533. async created() {
  534. this.customerContact = await this.getColumnData(this.getColumnName(24), customerContact);
  535. this.advantageProject = await this.getColumnData(this.getColumnName(25), advantageProject);
  536. this.getWorkDicts("procurement_method").then(res => {
  537. this.procurementMethodOption = res.data.data
  538. })
  539. wareHouseType().then(res => {
  540. this.warehouseType = res.data.data.records
  541. this.warehouseType.forEach(item => {
  542. this.$set(item, 'label', item.cname)
  543. this.$set(item, 'value', item.id)
  544. if (item.hasChildren) {
  545. this.$set(item, 'children', [])
  546. }
  547. })
  548. let result = [], temp = {}
  549. for(let i = 0; i < this.warehouseType.length;i++) {
  550. temp[this.warehouseType[i].id] = this.warehouseType[i]
  551. }
  552. for (let j = 0;j < this.warehouseType.length;j++) {
  553. let current = this.warehouseType[j]
  554. let tempCurrentParent = temp[current.parentId]
  555. if (tempCurrentParent) {
  556. if (!tempCurrentParent["children"]) {
  557. tempCurrentParent["children"] = []
  558. }
  559. tempCurrentParent["children"].push(current)
  560. } else {
  561. result.push(current)
  562. }
  563. }
  564. this.warehouseType = result
  565. });
  566. selectWareHouse().then(res => {
  567. this.warehouseName = res.data.data.records
  568. })
  569. if (this.detailData.id) {
  570. this.queryData(this.detailData.id)
  571. }else if (this.detailData.form){
  572. this.form = JSON.parse(this.detailData.form);
  573. delete this.form.createTime
  574. delete this.form.id
  575. delete this.form.sysNo
  576. this.contactsData = this.form.orderItemsList
  577. delete this.form.orderItemsList
  578. this.configuration.dicData = this.form.corpName
  579. delete this.form.corpName
  580. this.$set(this.form, 'deliveryStatus', '录入')
  581. if (this.form.belongToCorpList) {
  582. this.$set(this.form, 'salesCompany', this.form.belongToCorpId)
  583. delete this.form.belongToCorpId
  584. this.configuration.dicData = this.configuration.dicData.concat(this.form.belongToCorpList)
  585. }
  586. delete this.form.belongToCorpList
  587. this.$set(this.form, 'deliveryAmount', 0)
  588. this.$set(this.form, 'totalQuantity', 0)
  589. this.$set(this.form, 'purchaseAmount', 0)
  590. this.contactsData.forEach(item => {
  591. this.$set(item, "inventoryNumber", item.storageQuantity)
  592. this.$set(item, "srcId", item.id)
  593. this.$set(item, "deliveryAmount", item.amount)
  594. this.$set(item, "actualQuantity", (Number(item.purchaseQuantity) - Number(item.actualQuantity)))
  595. // 入库数量和入库金额的比例
  596. this.$set(item, 'scale', (item.deliveryAmount / item.actualQuantity))
  597. this.form.deliveryAmount += Number(item.deliveryAmount)
  598. this.form.totalQuantity += Number(item.actualQuantity)
  599. this.form.purchaseAmount += Number(item.deliveryAmount)
  600. this.form.deliveryAmount = (this.form.deliveryAmount).toFixed(2)
  601. this.form.purchaseAmount = (this.form.purchaseAmount).toFixed(2)
  602. delete item.id
  603. delete item.pid
  604. })
  605. } else if (this.detailData.copyId) {
  606. this.queryData(this.detailData.copyId, true)
  607. }
  608. },
  609. watch: {
  610. },
  611. methods: {
  612. queryData(id, isCopy = false) {
  613. detail(id).then(res => {
  614. console.log(res.data.data)
  615. this.form = res.data.data;
  616. this.contactsData = this.form.deliveryItemsList
  617. this.advantageProjectData = this.form.deliveryFeesList
  618. this.bankOfDepositData = this.form.deliveryFilesList
  619. this.configuration.dicData = this.form.corpName
  620. this.contactsData.forEach(item => {
  621. // this.form.deliveryAmount += Number(item.deliveryAmount)
  622. // this.form.totalQuantity += Number(item.actualQuantity)
  623. // 入库金额和入库数量的比例
  624. this.$set(item, 'scale', (item.deliveryAmount / item.actualQuantity))
  625. })
  626. let feesData = []
  627. this.form.deliveryFeesList.forEach(item => {
  628. let a = {
  629. cname: item.corpName,
  630. id: item.corpId
  631. }
  632. feesData.push(a)
  633. })
  634. this.configuration.dicData = this.configuration.dicData.concat(feesData)
  635. // 去重
  636. this.removeRepeat()
  637. if (this.form.companyName) {
  638. this.configuration.dicData = this.configuration.dicData.concat(this.form.companyName)
  639. }
  640. delete this.form.deliveryItemsList
  641. delete this.form.deliveryFeesList
  642. delete this.form.deliveryFilesList
  643. delete this.form.corpName
  644. delete this.form.companyName
  645. // 获取最大值
  646. let num = []
  647. this.advantageProjectData.forEach(item => {
  648. num.push(item.sort)
  649. })
  650. if (num.length == 0) {
  651. this.maxFeeNum = 0;
  652. } else {
  653. this.maxFeeNum = num.reduce((a, b) => {
  654. return b > a? b: a;
  655. })
  656. }
  657. let goodsNum = []
  658. this.contactsData.forEach(item => {
  659. goodsNum.push(item.sort)
  660. })
  661. if (goodsNum.length == 0) {
  662. this.maxGoodsNum = 0;
  663. } else {
  664. this.maxGoodsNum = goodsNum.reduce((a, b) => {
  665. return b > a? b: a;
  666. })
  667. }
  668. if (isCopy) {
  669. delete this.form.id
  670. delete this.form.sysNo
  671. this.contactsData.forEach(item => {
  672. delete item.id
  673. delete item.pid
  674. })
  675. this.advantageProjectData.forEach(item => {
  676. delete item.id
  677. delete item.pid
  678. })
  679. this.bankOfDepositData.forEach(item => {
  680. delete item.id
  681. delete item.pid
  682. })
  683. form.deliveryStatus == '录入'
  684. }
  685. });
  686. },
  687. copyOrder() {
  688. this.queryData(this.form.id, true)
  689. },
  690. // 入库数量变化时调用
  691. actualQuantityChange(row) {
  692. if (row.scale) {
  693. row.deliveryAmount = Number(row.actualQuantity) * Number(row.scale)
  694. }
  695. },
  696. // 类别变换时触发
  697. warehouseTreeChange(id) {
  698. this.warehouseName = []
  699. if (this.firstComing) {
  700. if (!this.form.storageId) {
  701. this.$set(this.form, 'storageId', null)
  702. } else {
  703. this.form.storageId = null
  704. }
  705. }
  706. let data = {
  707. storageTypeId: id
  708. }
  709. selectWareHouse(data).then(res => {
  710. this.warehouseName = res.data.data.records
  711. })
  712. this.firstComing = true
  713. },
  714. //点击行可编辑
  715. handleRowClick(row, event, column) {
  716. console.log(row.$index)
  717. },
  718. //商品编辑
  719. rowCell(row, index) {
  720. console.log(row)
  721. this.$refs.crudContact.rowCell(row, index)
  722. },
  723. //费用编辑
  724. rowCellTwo(row, index) {
  725. console.log(row)
  726. this.$refs.crudProject.rowCell(row, index)
  727. },
  728. //费用新增触发
  729. costIncrease() {
  730. this.dialogCost = !this.dialogCost
  731. this.choiceData = false
  732. },
  733. //商品新增触发
  734. commoditySelection() {
  735. this.dialogVisible = !this.dialogVisible
  736. this.tableData = []
  737. this.commodityData = false
  738. },
  739. //点击费用明细选择触发
  740. choice(row) {
  741. this.dialogCost = !this.dialogCost
  742. this.choiceData = true
  743. console.log(row)
  744. this.choiceIndex = row.$index
  745. },
  746. //点击商品明细选择触发
  747. commodityChoice(row) {
  748. this.dialogVisible = !this.dialogVisible
  749. this.commodityData = true
  750. console.log(row)
  751. this.choiceIndexT = row.$index
  752. },
  753. //导入商品触发
  754. importChoice() {
  755. if (this.tableData.length === 1) {
  756. this.contactsData[this.choiceIndexT].cname = this.tableData[0].cname
  757. this.contactsData[this.choiceIndexT].code = this.tableData[0].code
  758. this.contactsData[this.choiceIndexT].typeno = this.tableData[0].typeno
  759. this.contactsData[this.choiceIndexT].specificationAndModel = this.tableData[0].specificationAndModel
  760. this.contactsData[this.choiceIndexT].itemId = this.tableData[0].id
  761. selectGoodsNum({
  762. goodsId: this.tableData[0].id,
  763. typeno: this.tableData[0].typeno
  764. }).then(res => {
  765. this.contactsData[this.choiceIndexT].storageQuantity = res.data.data
  766. })
  767. }
  768. this.dialogVisible = !this.dialogVisible
  769. this.commodityData = false
  770. },
  771. //费用编辑导入触发
  772. choiceCost() {
  773. console.log('1111')
  774. if (this.tableDataCost.length === 1) {
  775. this.advantageProjectData[this.choiceIndex].feeName = this.tableDataCost[0].cname
  776. this.advantageProjectData[this.choiceIndex].itemId = this.tableDataCost[0].id
  777. this.advantageProjectData[this.choiceIndex].code = this.tableDataCost[0].code
  778. }
  779. this.dialogCost = !this.dialogCost
  780. this.choiceData = false
  781. },
  782. //费用导入触发
  783. importCost() {
  784. console.log('111111')
  785. // this.advantageProjectForm = this.advantageProjectForm.concat(this.tableDataCost)
  786. if (this.tableDataCost.length > 0) {
  787. for (let item in this.tableDataCost) {
  788. console.log(this.tableDataCost[item])
  789. this.tableDataCost[item].itemId = this.tableDataCost[item].id
  790. this.tableDataCost[item].feeName = this.tableDataCost[item].cname
  791. this.tableDataCost[item].sort = this.maxFeeNum + 1
  792. this.maxFeeNum++
  793. delete this.tableDataCost[item].id
  794. this.$refs.crudProject.rowCellAdd(this.tableDataCost[item]);
  795. this.$refs.crudProject.rowCell(this.tableDataCost[item], this.advantageProjectForm.length - 1)
  796. }
  797. }
  798. this.tableDataCost = []
  799. this.dialogCost = false
  800. },
  801. //确认导入触发
  802. importGoods() {
  803. // this.contactsData = this.contactsData.concat(this.tableData)
  804. if (this.tableData.length > 0) {
  805. for (let item in this.tableData) {
  806. selectGoodsNum({
  807. goodsId: this.tableData[item].id,
  808. typeno: this.tableData[item].typeno
  809. }).then(res => {
  810. this.tableData[item].storageQuantity = res.data.data
  811. this.tableData[item].itemId = this.tableData[item].id
  812. this.tableData[item].priceCategory = this.tableData[item].goodsTypeName
  813. delete this.tableData[item].goodsTypeName
  814. delete this.tableData[item].id
  815. delete this.tableData[item].status
  816. delete this.tableData[item].isDeleted
  817. this.$set(this.tableData[item], 'specificationAndModel', this.tableData[item].specificationAndModel)
  818. this.$set(this.tableData[item], 'purchaseQuantity', 0)
  819. this.$set(this.tableData[item], 'actualQuantity', 0)
  820. this.$set(this.tableData[item], 'purchaseAmount', 0)
  821. this.$set(this.tableData[item], 'deliveryAmount', 0)
  822. this.tableData[item].sort = this.maxGoodsNum + 1
  823. this.maxGoodsNum++
  824. this.$refs.crudContact.rowCellAdd(this.tableData[item]);
  825. this.$refs.crudContact.rowCell(this.tableData[item], this.contactsData.length - 1)
  826. })
  827. }
  828. }
  829. this.dialogVisible = false
  830. },
  831. closeGoods() {
  832. this.treeDataGoods = [];
  833. this.treeDeptId = "";
  834. },
  835. closeFees() {
  836. this.treeDeptIdCost = "";
  837. this.treeData = [];
  838. },
  839. //选中触发
  840. selectionChange(list) {
  841. console.log(list);
  842. this.tableData = list
  843. },
  844. //费用选中触发
  845. selectionChangeCost(list) {
  846. console.log(list);
  847. this.tableDataCost = list
  848. },
  849. //导入页左商品类型查询
  850. nodeClick(data) {
  851. this.treeDeptId = data.id;
  852. this.page.currentPage = 1;
  853. this.onLoad(this.page);
  854. },
  855. //导入页左费用类型查询
  856. nodeClickCost(data) {
  857. this.treeDeptIdCost = data.id;
  858. this.pageCost.currentPage = 1;
  859. this.onLoadCost(this.pageCost);
  860. },
  861. //刷新触发
  862. refreshChange() {
  863. this.treeDeptId = '';
  864. this.page.currentPage = 1;
  865. this.onLoad(this.page);
  866. },
  867. //费用刷新触发
  868. refreshChangeCost() {
  869. this.treeDeptIdCost = '';
  870. this.pageCost.currentPage = 1;
  871. this.onLoadCost(this.pageCost);
  872. },
  873. //新增商品信息保存触发
  874. rowSave(row, done, loading) {
  875. console.log(row)
  876. console.log(this.contactsData)
  877. // this.contactsData.push(row)
  878. done()
  879. },
  880. //修改商品信息触发
  881. rowUpdate(row, index, done, loading) {
  882. done(row);
  883. },
  884. //删除商品信息触发
  885. rowDel(row, index, donerowDel) {
  886. this.$confirm("确定将选择数据删除?", {
  887. confirmButtonText: "确定",
  888. cancelButtonText: "取消",
  889. type: "warning"
  890. }).then(() => {
  891. //商品判断是否需要调用删除接口
  892. if (row.id) {
  893. corpsattn(row.id).then(res => {
  894. this.$message({
  895. type: "success",
  896. message: "操作成功!"
  897. });
  898. this.contactsData.splice(index, 1);
  899. })
  900. } else {
  901. this.$message({
  902. type: "success",
  903. message: "操作成功!"
  904. });
  905. this.contactsData.splice(index, 1);
  906. }
  907. })
  908. },
  909. //新增费用明细保存触发
  910. rowSaveProject(row, done, loading) {
  911. // this.advantageProjectData.push(row)
  912. done()
  913. },
  914. //修改费用明细触发
  915. rowUpdateProject(row, index, done, loading) {
  916. done(row);
  917. },
  918. //商品列表查询
  919. onLoad(page, params = {}) {
  920. this.loading = true;
  921. getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
  922. console.log(res)
  923. const data = res.data.data;
  924. this.page.total = data.total;
  925. this.data = data.records;
  926. this.loading = false;
  927. });
  928. },
  929. //费用查询
  930. onLoadCost(page, params = {}) {
  931. this.loadingCost = true;
  932. let queryParams = Object.assign({}, params, {
  933. pageSize: page.pageSize,
  934. pageNum: page.currentPage,
  935. parentId: 0,
  936. feesTypeId: this.treeDeptIdCost
  937. })
  938. customerList(queryParams).then(res => {
  939. console.log(res)
  940. const data = res.data.data;
  941. this.pageCost.total = data.total;
  942. this.dataCost = data.records;
  943. this.loadingCost = false;
  944. });
  945. },
  946. //删除费用明细触发
  947. rowDelProject(row, index, donerowDel) {
  948. this.$confirm("确定将选择数据删除?", {
  949. confirmButtonText: "确定",
  950. cancelButtonText: "取消",
  951. type: "warning"
  952. }).then(() => {
  953. //费用判断是否需要调用删除接口
  954. if (row.id) {
  955. corpsitem(row.id).then(res => {
  956. this.$message({
  957. type: "success",
  958. message: "操作成功!"
  959. });
  960. this.advantageProjectData.splice(index, 1);
  961. })
  962. } else {
  963. this.$message({
  964. type: "success",
  965. message: "操作成功!"
  966. });
  967. this.advantageProjectData.splice(index, 1);
  968. }
  969. })
  970. },
  971. //新增附件上传保存触发
  972. rowSaveBankOfDeposit(row, done, loading) {
  973. this.bankOfDepositData.push(row)
  974. done()
  975. },
  976. //修改附件上传触发
  977. rowUpdateBankOfDeposit(row, index, done, loading) {
  978. done(row);
  979. },
  980. //删除附件上传触发
  981. rowDelBankOfDeposit(row, index, donerowDel) {
  982. this.$confirm("确定将选择数据删除?", {
  983. confirmButtonText: "确定",
  984. cancelButtonText: "取消",
  985. type: "warning"
  986. }).then(() => {
  987. //附件判断是否需要调用删除接口
  988. if (row.id) {
  989. corpsbank(row.id).then(res => {
  990. this.$message({
  991. type: "success",
  992. message: "操作成功!"
  993. });
  994. this.bankOfDepositData.splice(index, 1);
  995. })
  996. } else {
  997. this.$message({
  998. type: "success",
  999. message: "操作成功!"
  1000. });
  1001. this.bankOfDepositData.splice(index, 1);
  1002. }
  1003. })
  1004. },
  1005. uploadAfter(res, done) {
  1006. if (res.originalName) {
  1007. this.bankOfDepositForm.fileName = this.bankOfDepositForm.fileName
  1008. ? this.bankOfDepositForm.fileName
  1009. : res.originalName;
  1010. }
  1011. done();
  1012. },
  1013. // 去重
  1014. removeRepeat() {
  1015. let obj = []
  1016. this.configuration.dicData = this.configuration.dicData.reduce((current,next) => {
  1017. obj[next.id] ? '': obj[next.id] = true && current.push(next)
  1018. return current
  1019. }, [])
  1020. },
  1021. receiveList(data){
  1022. this.configuration.dicData = this.configuration.dicData.concat(data)
  1023. this.removeRepeat()
  1024. },
  1025. // 确认收货
  1026. sendInGoods() {
  1027. this.$refs["form"].validate((valid) => {
  1028. if (valid) {
  1029. if (this.contactsData.length == 0) {
  1030. return this.$message.error('商品信息为空')
  1031. }
  1032. for (let item in this.contactsData) {
  1033. if (!this.contactsData[item].id) {
  1034. return this.$message.error('有商品未保存,请先保存')
  1035. }
  1036. }
  1037. //商品信息
  1038. this.form.deliveryItemsList = this.contactsData
  1039. this.form.deliveryFeesList = this.advantageProjectData
  1040. this.form.deliveryFilesList = this.bankOfDepositData
  1041. if (typeof this.form.corpsTypeId == 'object') {
  1042. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1043. }
  1044. sendInGoods(this.form).then(res => {
  1045. console.log(res)
  1046. this.$message.success('收货成功')
  1047. this.queryData(res.data.data.id)
  1048. })
  1049. } else {
  1050. return false;
  1051. }
  1052. });
  1053. },
  1054. // 撤销收货
  1055. revokeInGoods() {
  1056. this.$refs["form"].validate((valid) => {
  1057. if (valid) {
  1058. //商品信息
  1059. this.form.deliveryItemsList = this.contactsData
  1060. this.form.deliveryFeesList = this.advantageProjectData
  1061. this.form.deliveryFilesList = this.bankOfDepositData
  1062. if (typeof this.form.corpsTypeId == 'object') {
  1063. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1064. }
  1065. revokeInGoods(this.form).then(res => {
  1066. this.$message.success('撤销成功')
  1067. this.queryData(res.data.data.id)
  1068. })
  1069. } else {
  1070. return false;
  1071. }
  1072. });
  1073. },
  1074. //修改提交触发
  1075. editCustomer(isBack = false) {
  1076. console.log(this.form)
  1077. this.$refs["form"].validate((valid) => {
  1078. if (valid) {
  1079. this.form.deliveryAmount = 0
  1080. this.form.totalQuantity = 0
  1081. this.form.purchaseAmount = 0
  1082. this.contactsData.forEach(item => {
  1083. this.form.deliveryAmount += Number(item.deliveryAmount)
  1084. this.form.totalQuantity += Number(item.actualQuantity)
  1085. this.form.purchaseAmount += Number(item.deliveryAmount)
  1086. this.form.deliveryAmount = (this.form.deliveryAmount).toFixed(2)
  1087. this.form.purchaseAmount = (this.form.purchaseAmount).toFixed(2)
  1088. })
  1089. //商品信息
  1090. this.form.deliveryItemsList = this.contactsData
  1091. this.form.deliveryFeesList = this.advantageProjectData
  1092. this.form.deliveryFilesList = this.bankOfDepositData
  1093. if (typeof this.form.corpsTypeId == 'object') {
  1094. this.form.corpsTypeId = this.form.corpsTypeId.join(",")
  1095. }
  1096. this.disabled = true
  1097. typeSave(this.form).then(res => {
  1098. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  1099. this.disabled = false
  1100. if (isBack) {
  1101. //成功关闭此页面回到列表页
  1102. this.$emit("goBack");
  1103. } else {
  1104. this.queryData(res.data.data.id)
  1105. }
  1106. })
  1107. } else {
  1108. return false;
  1109. }
  1110. });
  1111. },
  1112. //返回列表
  1113. backToList() {
  1114. this.$confirm("是否保存当前页面?", "提示", {
  1115. confirmButtonText: "保存",
  1116. cancelButtonText: "取消",
  1117. type: "warning",
  1118. }).then(() => {
  1119. this.editCustomer(true)
  1120. }).catch(() => {
  1121. this.$emit("goBack");
  1122. })
  1123. },
  1124. // 保存列设置
  1125. async saveColumn(name) {
  1126. /**
  1127. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  1128. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  1129. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  1130. */
  1131. if (name == 'goods') {
  1132. const inSave = await this.saveColumnData(
  1133. this.getColumnName(24),
  1134. this.customerContact
  1135. );
  1136. if (inSave) {
  1137. this.$message.success("保存成功");
  1138. //关闭窗口
  1139. this.$refs.crudContact.$refs.dialogColumn.columnBox = false;
  1140. }
  1141. } else if (name === 'fees') {
  1142. const inSave = await this.saveColumnData(
  1143. this.getColumnName(25),
  1144. this.advantageProject
  1145. );
  1146. if (inSave) {
  1147. this.$message.success("保存成功");
  1148. //关闭窗口
  1149. this.$refs.crudProject.$refs.dialogColumn.columnBox = false;
  1150. }
  1151. }
  1152. },
  1153. }
  1154. }
  1155. </script>
  1156. <style lang="scss" scoped>
  1157. .customer-head {
  1158. position: fixed;
  1159. top: 105px;
  1160. width: 100%;
  1161. margin-left: -10px;
  1162. height: 62px;
  1163. background: #ffffff;
  1164. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  1165. z-index: 999;
  1166. /* display: flex;
  1167. justify-content: left; */
  1168. }
  1169. .customer-back {
  1170. cursor: pointer;
  1171. line-height: 62px;
  1172. font-size: 16px;
  1173. color: #323233;
  1174. font-weight: 400;
  1175. }
  1176. .back-icon {
  1177. line-height: 64px;
  1178. font-size: 20px;
  1179. margin-right: 8px;
  1180. }
  1181. .add-customer-btn {
  1182. position: fixed;
  1183. right: 36px;
  1184. top: 115px;
  1185. }
  1186. ::v-deep .el-form-item {
  1187. margin-bottom: 0;
  1188. }
  1189. .el-dialogDeep {
  1190. ::v-deep .el-dialog {
  1191. margin: 1vh auto 0 !important;
  1192. padding-bottom: 10px !important;
  1193. .el-dialog__body, .el-dialog__footer {
  1194. padding-bottom: 0 !important;
  1195. padding-top: 0 !important;
  1196. }
  1197. }
  1198. }
  1199. .print-div {
  1200. color: #000;
  1201. }
  1202. .print_table {
  1203. table {
  1204. border-right: 1px solid #000;
  1205. border-bottom: 1px solid #000;
  1206. font-size: 12px;
  1207. margin-bottom: 5px;
  1208. }
  1209. table td {
  1210. border-left: 1px solid #000;
  1211. border-top: 1px solid #000;
  1212. vertical-align: middle;
  1213. padding: 2px;
  1214. text-align: center;
  1215. }
  1216. }
  1217. .table {
  1218. border-collapse: collapse;
  1219. border-spacing: 0;
  1220. background-color: transparent;
  1221. display: table;
  1222. width: 99%;
  1223. max-width: 100%;
  1224. margin: 0 auto;
  1225. }
  1226. .table td {
  1227. text-align: left;
  1228. vertical-align: middle;
  1229. font-size: 14px;
  1230. color: #000000;
  1231. padding: 10.5px 0 10.5px 30px;
  1232. //border: 1px solid #000;
  1233. }
  1234. </style>