detailsPage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <el-button type="primary" size="small" :disabled="form.status>0" v-if="detailData.status == 1"
  11. class="el-button--small-yh " @click.stop="openEdit">编辑
  12. </el-button>
  13. <el-button type="primary" @click="editCustomer" :loading="subLoading" v-if="detailData.status != 1"
  14. size="small">保存数据
  15. </el-button>
  16. <el-dropdown style="padding: 0 6px;line-height: 0">
  17. <el-button type="primary" size="small" :loading="subLoading" :disabled="!form.id">
  18. 审核处理<i class="el-icon-arrow-down el-icon--right"></i>
  19. </el-button>
  20. <el-dropdown-menu slot="dropdown">
  21. <el-dropdown-item :disabled="form.status>0" @click.native="auditCheck">提交审核</el-dropdown-item>
  22. <el-dropdown-item :disabled="form.status<1" @click.native="checkScheduleDialog = true">审核进度
  23. </el-dropdown-item>
  24. </el-dropdown-menu>
  25. </el-dropdown>
  26. </div>
  27. </div>
  28. <div class="customer-main" v-loading="subLoading">
  29. <trade-card title="基础信息">
  30. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  31. <template slot="purchaserId">
  32. <crop-select v-model="form.purchaserId" corpType="KH" :refresh="false" @getCorpData="getKHData"
  33. :disabled="detailData.status == 1"></crop-select>
  34. </template>
  35. <template slot="corpId">
  36. <crop-select v-model="form.corpId" corpType="GYS" :refresh="false" @getCorpData="getGYSData"
  37. :disabled="detailData.status == 1"></crop-select>
  38. </template>
  39. <template slot="storageId">
  40. <el-cascader v-model="form.storageId" :options="storagetreeList" :show-all-levels="false"
  41. :disabled="detailData.status == 1" :props="{ checkStrictly: true, emitPath: false, label: 'title' }"
  42. clearable @change="storagetreeChange">
  43. </el-cascader>
  44. </template>
  45. </avue-form>
  46. </trade-card>
  47. <trade-card title="入库明细">
  48. <avue-crud ref="crud" :data="itemsVOList" :option="tableOption" @row-del="rowDel" @saveColumn="saveColumn"
  49. @resetColumn="resetColumn" :cell-style="cellStyle" @row-save="rowSave" @row-update="addUpdate">
  50. <template slot="menuLeft">
  51. <el-button type="primary" icon="el-icon-plus" size="small" :disabled="detailData.status == 1"
  52. @click.stop="addRow">录入明细
  53. </el-button>
  54. <!-- <el-button type="success" icon="el-icon-bottom" size="small" @click.stop="getTemplate">下载模板</el-button>-->
  55. <el-button type="info" icon="el-icon-top" size="small" :disabled="detailData.status == 1"
  56. @click.stop="excelBox = true">导入
  57. </el-button>
  58. </template>
  59. <template slot="headerSerial">
  60. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  61. :disabled="detailData.status == 1" circle></el-button>
  62. </template>
  63. <template slot="oneCode" slot-scope="{ row, index }">
  64. <el-popover placement="right" width="160" trigger="click">
  65. <el-image style="width: 160px; height: 80px" :src="row.oneCode" :fit="fit"></el-image>
  66. <el-button v-if="row.oneCode" type="text" slot="reference">查看</el-button>
  67. </el-popover>
  68. </template>
  69. <template slot="qrCode" slot-scope="{ row, index }">
  70. <el-popover placement="right" width="300" trigger="click">
  71. <el-image style="width: 300px; height: 300px" :src="row.qrCode" :fit="fit"></el-image>
  72. <el-button v-if="row.qrCode" type="text" slot="reference">查看</el-button>
  73. </el-popover>
  74. </template>
  75. <template slot="storageInQuantityForm" slot-scope="{ row }">
  76. <el-input-number size="small" v-model="row.storageInQuantity" @change="calculateChange(row)"
  77. :controls="false" style="width:100%" placeholder="请输入"></el-input-number>
  78. </template>
  79. <template slot="priceForm" slot-scope="{ row }">
  80. <el-input-number size="small" v-model="row.price" @change="calculateChange(row)" :controls="false"
  81. style="width:100%" placeholder="请输入"></el-input-number>
  82. </template>
  83. <template slot="menu" slot-scope="{ row, index }">
  84. <div style="display:flex;justify-content: center;">
  85. <el-button size="small" icon="el-icon-edit" type="text" @click="rowCell(row, index)"
  86. :disabled="disabled || detailData.status == 1">{{ row.$cellEdit ? "保存" : "编辑" }}</el-button>
  87. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)"
  88. :disabled="detailData.status == 1">删除</el-button>
  89. <el-button size="small" icon="el-icon-printer" type="text" @click="rowPrint(row, index)"
  90. :disabled="!row.id">
  91. 打印</el-button>
  92. <div style="display:flex;flex-direction: column;justify-content: center;margin-left: 10px;">
  93. <el-tooltip effect="dark" content="向上移动" placement="top">
  94. <i v-if="index != 0" :disabled="detailData.status == 1" class="el-icon-arrow-up"
  95. @click="moveUp(row, index)" style="color:#409EFF;"></i>
  96. </el-tooltip>
  97. <el-tooltip effect="dark" content="向下移动" placement="bottom"> <i v-if="index != (itemsVOList.length - 1)"
  98. :disabled="detailData.status == 1" class="el-icon-arrow-down" @click="moveDown(row, index)"
  99. style="color:#409EFF;"></i></el-tooltip>
  100. </div>
  101. </div>
  102. </template>
  103. </avue-crud>
  104. </trade-card>
  105. <fee-info ref="feeInfo" :orderFeesList="orderFeesList" :disabled="detailData.status == 1"
  106. feeUrl="/blade-purchase-sales/entranceOrder/removeOrderFees" :optionType="'CMY'" :itemType="'C'"
  107. :inCropId="true" :tabShow="3" @beforeFinance="beforeFinance" :delType="2" :billingShow="false" />
  108. <upload-file ref="uploadFile" title="合同附件" :disabled="detailData.status == 1" :orderFilesList="orderFilesList"
  109. delUrl="" />
  110. <el-dialog append-to-body title="审核进度" class="el-dialogDeep" :visible.sync="checkScheduleDialog" width="40%"
  111. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
  112. <check-schedule :checkId="form.id" :batchNo="batchNo" @choceScheduleFun="choceScheduleFun">
  113. </check-schedule>
  114. </el-dialog>
  115. </div>
  116. <el-dialog title="导入" append-to-body :close-on-click-modal="false" :visible.sync="excelBox" width="555px">
  117. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter" :upload-error="uploadError">
  118. <template slot="excelTemplate">
  119. <el-button type="primary" @click="getTemplate">
  120. 点击下载<i class="el-icon-download el-icon--right"></i>
  121. </el-button>
  122. </template>
  123. </avue-form>
  124. <p style="text-align: center;color: #DC0505">
  125. 温馨提示 第一次导入时请先下载模板
  126. </p>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. import { detail, submit, checkWarehousing, getStoragetree, getStorage, getAllgoods, delItem } from "@/api/purchasingManagement/inStock";
  132. import tableOption from "./config/customerContact.json";
  133. import feeInfo from "@/components/fee-info/main";
  134. import checkSchedule from "../../../components/check/checkSchedule";
  135. import uploadFile from "@/components/upload-file/main";
  136. import { getToken } from "@/util/auth";
  137. import { contrastObj, contrastList } from "@/util/contrastData";
  138. export default {
  139. name: "detailsPageEdit",
  140. data() {
  141. return {
  142. subLoading: false,
  143. buttonLoading: false,
  144. form: {},
  145. excelBox: false,
  146. excelOption: {
  147. submitBtn: false,
  148. emptyBtn: false,
  149. column: [
  150. {
  151. label: '模板下载',
  152. prop: 'excelTemplate',
  153. formslot: true,
  154. span: 24,
  155. }, {
  156. label: '模板上传',
  157. prop: 'excelFile',
  158. type: 'upload',
  159. drag: true,
  160. loadText: '模板上传中,请稍等',
  161. span: 24,
  162. propsHttp: {
  163. res: 'data'
  164. },
  165. tip: '请上传 .xls,.xlsx 标准格式文件',
  166. action: "/api/trade-purchase/woodHarvestingCloud/import"
  167. }
  168. ]
  169. },
  170. excelForm: {},
  171. checkScheduleDialog: false,
  172. tableOption: {},
  173. option: {
  174. disabled: false,
  175. menuBtn: false,
  176. labelWidth: 100,
  177. column: [
  178. {
  179. label: "货权人",
  180. prop: "purchaserId",
  181. rules: [
  182. {
  183. required: true,
  184. message: "",
  185. trigger: "blur"
  186. }
  187. ],
  188. span: 6
  189. },
  190. {
  191. label: "入库日期",
  192. prop: "stockTime",
  193. type: "datetime",
  194. format: "yyyy-MM-dd HH:mm:ss",
  195. valueFormat: "yyyy-MM-dd HH:mm:ss",
  196. rules: [
  197. {
  198. required: true,
  199. message: "",
  200. trigger: "blur"
  201. }
  202. ],
  203. span: 6
  204. },
  205. {
  206. label: "仓库",
  207. prop: "storageId",
  208. rules: [
  209. {
  210. required: true,
  211. message: "",
  212. trigger: "blur"
  213. }
  214. ],
  215. span: 6
  216. },
  217. {
  218. label: "提单号",
  219. prop: "billNo",
  220. span: 6
  221. },
  222. {
  223. label: "业务类型",
  224. prop: "businessType",
  225. type: "select",
  226. props: {
  227. label: "dictValue",
  228. value: "dictKey"
  229. },
  230. dicData: [],
  231. span: 6
  232. },
  233. {
  234. label: "车船号",
  235. prop: "vehicleShipNumber",
  236. span: 6
  237. },
  238. {
  239. label: "供应商",
  240. prop: "corpId",
  241. span: 6
  242. },
  243. {
  244. label: "入库单号",
  245. prop: "sysNo",
  246. disabled: true,
  247. span: 6
  248. },
  249. {
  250. label: "审核状态",
  251. prop: "status",
  252. type: "select",
  253. dataType: 'number',
  254. props: {
  255. label: "dictValue",
  256. value: "dictKey"
  257. },
  258. dicData: [],
  259. disabled: true,
  260. span: 6
  261. },
  262. {
  263. label: "备注",
  264. prop: "orderRemark",
  265. type: "textarea",
  266. minRows: 2,
  267. span: 18
  268. },
  269. ]
  270. },
  271. itemsVOList: [],
  272. orderFeesList: [],
  273. orderFilesList: [],
  274. pageLoading: false,
  275. batchNo: '',
  276. storagetreeList: [],
  277. oldform: {},
  278. olditemsVOList: [],
  279. oldorderFeesList: [],
  280. oldorderFilesList: [],
  281. };
  282. },
  283. props: {
  284. detailData: {
  285. type: Object
  286. }
  287. },
  288. components: {
  289. feeInfo,
  290. checkSchedule,
  291. uploadFile
  292. },
  293. async created() {
  294. if (this.detailData.status == 1) {
  295. this.option.disabled = true;
  296. }
  297. if (this.detailData.id) {
  298. this.getDetail(this.detailData.id);
  299. }
  300. this.tableOption = await this.getColumnData(
  301. this.getColumnName(189),
  302. tableOption
  303. );
  304. getStoragetree().then(res => {
  305. this.storagetreeList = res.data.data;
  306. })
  307. this.getWorkDicts("approval_status").then(res => {
  308. this.findObject(this.option.column, "status").dicData =
  309. res.data.data;
  310. });
  311. this.getWorkDicts("CMY_business_type").then(res => {
  312. this.findObject(this.option.column, "businessType").dicData =
  313. res.data.data;
  314. });
  315. getAllgoods().then(res => {
  316. this.findObject(this.tableOption.column, "itemId").dicData =
  317. res.data.data;
  318. })
  319. this.getWorkDicts("unit").then(res => {
  320. this.findObject(this.tableOption.column, "unit").dicData =
  321. res.data.data;
  322. });
  323. },
  324. methods: {
  325. cellStyle() {
  326. return "padding:0;height:40px;";
  327. },
  328. getStorage() {
  329. getStorage({ storageTypeId: this.form.storageId }).then(res => {
  330. this.findObject(this.tableOption.column, "storageId").dicData = res.data;
  331. })
  332. },
  333. storagetreeChange(row) {
  334. if (row) {
  335. if (this.itemsVOList.length > 0) {
  336. this.getStorage()
  337. this.itemsVOList.forEach(e => {
  338. e.storageId = null
  339. })
  340. this.$message.warning("请重新选择库区!")
  341. }
  342. } else {
  343. if (this.itemsVOList.length > 0) {
  344. this.findObject(this.tableOption.column, "storageId").dicData = []
  345. this.itemsVOList.forEach(e => {
  346. e.storageId = null
  347. })
  348. this.$message.warning("请重新选择库区!")
  349. }
  350. }
  351. },
  352. getKHData(row) {
  353. this.form.purchaser = row.cname
  354. },
  355. getGYSData(row) {
  356. console.log(row)
  357. this.form.corpName = row.cname
  358. },
  359. choceScheduleFun() {
  360. this.checkScheduleDialog = false
  361. },
  362. addRow() {
  363. this.$refs["form"].validate((valid, done) => {
  364. done();
  365. if (valid) {
  366. this.itemsVOList.push({ $cellEdit: true, unit: '1' });
  367. this.getStorage()
  368. } else {
  369. return false;
  370. }
  371. });
  372. },
  373. rowCell(row, index) {
  374. this.$refs.crud.rowCell(row, index)
  375. },
  376. rowSave(form, done) {
  377. done()
  378. },
  379. addUpdate(form, index, done, loading) {
  380. done()
  381. },
  382. rowDel(row) {
  383. this.$confirm("确定删除数据?", {
  384. confirmButtonText: "确定",
  385. cancelButtonText: "取消",
  386. type: "warning"
  387. }).then(() => {
  388. if (row.id) {
  389. delItem({ itemId: row.id }).then(res => {
  390. this.$message({
  391. type: "success",
  392. message: "删除成功!"
  393. });
  394. this.itemsVOList.splice(row.$index, 1);
  395. });
  396. } else {
  397. this.$message({
  398. type: "success",
  399. message: "删除成功!"
  400. });
  401. this.itemsVOList.splice(row.$index, 1);
  402. }
  403. });
  404. },
  405. getDetail(id) {
  406. this.pageLoading = true;
  407. detail(id)
  408. .then(res => {
  409. this.form = res.data.data;
  410. this.itemsVOList = res.data.data.itemsVOList;
  411. this.orderFeesList = res.data.data.orderFeesList;
  412. this.orderFilesList = res.data.data.orderFilesList;
  413. this.oldform = this.deepClone(res.data.data);
  414. this.olditemsVOList = this.deepClone(res.data.data.itemsVOList);
  415. this.oldorderFeesList = this.deepClone(res.data.data.orderFeesList);
  416. this.oldorderFilesList = this.deepClone(res.data.data.orderFilesList);
  417. this.getStorage()
  418. })
  419. .finally(() => {
  420. this.pageLoading = false;
  421. });
  422. },
  423. rowPrint(row) {
  424. this.$router.push(`/myiframe/urlPath?name=preview-木材管理-入库垛卡.ureport.xml&src=${this.website.reportUrl}/preview?_u=blade-木材管理-入库垛卡.ureport.xml&id=${row.id}`);
  425. },
  426. //修改提交触发
  427. editCustomer(status) {
  428. this.$refs["form"].validate((valid, done) => {
  429. done();
  430. if (valid) {
  431. for (let i = 0; i < this.itemsVOList.length; i++) {
  432. if (this.itemsVOList[i].$cellEdit) {
  433. return this.$message.error('请保存明细')
  434. }
  435. }
  436. let orderFeesList = this.$refs.feeInfo.submitData();
  437. this.subLoading = true;
  438. this.buttonLoading = false;
  439. let data = {
  440. ...this.form,
  441. billType: 'RK',
  442. itemsVOList: this.itemsVOList,
  443. orderFeesList: orderFeesList,
  444. orderFilesList: this.orderFilesList
  445. };
  446. submit(data).then(res => {
  447. this.form = res.data.data;
  448. this.itemsVOList = res.data.data.itemsVOList;
  449. this.orderFeesList = res.data.data.orderFeesList;
  450. this.orderFilesList = res.data.data.orderFilesList;
  451. this.oldform = this.deepClone(res.data.data);
  452. this.olditemsVOList = this.deepClone(res.data.data.itemsVOList);
  453. this.oldorderFeesList = this.deepClone(res.data.data.orderFeesList);
  454. this.oldorderFilesList = this.deepClone(res.data.data.orderFilesList);
  455. this.$message({
  456. type: "success",
  457. message: "保存成功!"
  458. });
  459. if (status == "goBack") {
  460. this.$emit("goBack");
  461. }
  462. })
  463. .finally(() => {
  464. this.subLoading = false;
  465. this.buttonLoading = false;
  466. });
  467. } else {
  468. return false;
  469. }
  470. });
  471. },
  472. //请核
  473. auditCheck() {
  474. let orderFeesList = this.$refs.feeInfo.submitData();
  475. if (orderFeesList.length == 0) {
  476. this.$confirm("没有应付费用,是否继续提交?", {
  477. confirmButtonText: "确定",
  478. cancelButtonText: "取消",
  479. type: "warning"
  480. }).then(() => {
  481. this.$confirm("确定审核此订单?", {
  482. confirmButtonText: "确定",
  483. cancelButtonText: "取消",
  484. type: "warning"
  485. }).then(() => {
  486. this.buttonLoading = true
  487. const data = {
  488. id: this.form.id,
  489. checkType: 'RK',
  490. url: '/purchasingManagement/inStock/index',
  491. pageStatus: "this.$store.getters.entranceXsStatus",
  492. pageLabel: "入库管理",
  493. checkFlag: 1,
  494. }
  495. checkWarehousing(data).then(res => {
  496. if (res.data.success) {
  497. this.$message.success("操作成功!")
  498. this.viewDisabled = true
  499. this.approverDisabled = true
  500. }
  501. })
  502. }).finally(() => {
  503. this.buttonLoading = false
  504. })
  505. })
  506. } else {
  507. this.$confirm("确定审核此订单?", {
  508. confirmButtonText: "确定",
  509. cancelButtonText: "取消",
  510. type: "warning"
  511. }).then(() => {
  512. this.buttonLoading = true
  513. const data = {
  514. id: this.form.id,
  515. checkType: 'RK',
  516. url: '/purchasingManagement/inStock/index',
  517. pageStatus: "this.$store.getters.entranceXsStatus",
  518. pageLabel: "入库管理",
  519. checkFlag: 1,
  520. }
  521. checkWarehousing(data).then(res => {
  522. if (res.data.success) {
  523. this.$message.success("操作成功!")
  524. this.viewDisabled = true
  525. this.approverDisabled = true
  526. }
  527. })
  528. }).finally(() => {
  529. this.buttonLoading = false
  530. })
  531. }
  532. },
  533. calculateChange(row) {
  534. row.storageAmount = (row.storageInQuantity ? row.storageInQuantity : 0) * (row.price ? row.price : 0)
  535. },
  536. beforeFinance(feesData, callback) {
  537. let params = {}
  538. //暂时默认通过 之后优化
  539. params.valid = true
  540. params.parentId = this.form.id
  541. callback(params)
  542. },
  543. getTemplate() {
  544. window.open(`/api/trade-purchase/woodHarvestingCloud/export-template?${this.website.tokenHeader}=${getToken()}`)
  545. },
  546. uploadAfter(res, done, loading, column) {
  547. if (!res.message){
  548. res.forEach(item => this.itemsVOList.push({
  549. ...item,
  550. $cellEdit: true
  551. }))
  552. this.excelBox = false
  553. done();
  554. }else {
  555. loading()
  556. }
  557. },
  558. //返回列表
  559. backToList() {
  560. let orderFeesList = this.$refs.feeInfo.submitData();
  561. if (
  562. contrastObj(this.form, this.oldform) ||
  563. contrastList(this.itemsVOList, this.olditemsVOList) ||
  564. contrastList(orderFeesList, this.oldorderFeesList) ||
  565. contrastList(this.orderFilesList, this.oldorderFilesList)
  566. ) {
  567. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  568. confirmButtonText: "确定",
  569. cancelButtonText: "取消",
  570. type: "warning"
  571. })
  572. .then(() => {
  573. this.editCustomer("goBack");
  574. })
  575. .catch(() => {
  576. this.$emit("goBack");
  577. });
  578. } else {
  579. this.$emit("goBack");
  580. }
  581. },
  582. openEdit() {
  583. this.detailData.status = 2;
  584. this.option.disabled = false;
  585. this.$refs.crud.refreshTable();
  586. },
  587. async saveColumn() {
  588. const inSave = await this.saveColumnData(
  589. this.getColumnName(189),
  590. this.tableOption
  591. );
  592. if (inSave) {
  593. this.$nextTick(() => {
  594. this.$refs.crud.doLayout();
  595. });
  596. this.$message.success("保存成功");
  597. //关闭窗口
  598. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  599. }
  600. },
  601. moveUp(row, index) {
  602. this.itemsVOList[index] = this.itemsVOList.splice(index - 1, 1, row)[0]
  603. },
  604. moveDown(row, index) {
  605. this.itemsVOList[index] = this.itemsVOList.splice(index + 1, 1, row)[0]
  606. },
  607. async resetColumn() {
  608. this.tableOption = tableOption;
  609. const inSave = await this.delColumnData(
  610. this.getColumnName(189),
  611. tableOption
  612. );
  613. if (inSave) {
  614. this.$nextTick(() => {
  615. this.$refs.crud.doLayout();
  616. });
  617. this.$message.success("重置成功");
  618. //关闭窗口
  619. setTimeout(() => {
  620. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  621. }, 1000);
  622. }
  623. }
  624. },
  625. watch: {
  626. }
  627. };
  628. </script>
  629. <style lang="scss" scoped>
  630. .trading-form ::v-deep .el-form-item {
  631. margin-bottom: 8px !important;
  632. }
  633. ::v-deep .el-form-item__error {
  634. display: none !important;
  635. }
  636. ::v-deep .select-component {
  637. display: flex !important;
  638. }
  639. </style>