detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList" :loading="btnLoading">返回列表</el-button>
  7. </div>
  8. <div class="add-customer-btn">
  9. <el-button type="primary" size="small" class="el-button--small-yh" @click.stop="openEdit" v-if="disabled">编 辑
  10. </el-button>
  11. <el-button v-if="
  12. form.id &&
  13. form.confirmStatus !== 1
  14. " type="primary" size="small" class="el-button--small-yh" :loading="btnLoading" @click="submitConfirm"
  15. :disabled="!form.id || disabled">提交确认</el-button>
  16. <el-button v-if="checker && form.status != 3" type="primary" size="small" class="el-button--small-yh"
  17. @click.stop="openCheckDialog">
  18. 审批
  19. </el-button>
  20. <el-button v-if="form.status > 0" @click.native="(checkScheduleDialog = true), (checkId = form.id)"
  21. type="primary" size="small">审核进度</el-button>
  22. <el-button type="primary" v-if="!checkDisabled" :disabled="!form.id || disabled || form.confirmStatus !== 1"
  23. size="small" @click="pleaseCheck" :loading="btnLoading">请核</el-button>
  24. <el-button type="success" :disabled="!form.id" size="small" @click="copyDoc" :loading="btnLoading" v-if="false">
  25. 复制单据</el-button>
  26. <el-button type="primary" @click="editCustomer" size="small" :loading="btnLoading">保存数据</el-button>
  27. </div>
  28. </div>
  29. <div class="customer-main">
  30. <containerTitle title="基础信息" />
  31. <basic-container :showBtn="true">
  32. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  33. <template slot="corpId">
  34. <crop-select v-model="form.corpId" @getCorpData="getKHData" corpType="KH"
  35. :disabled="disabled || checkDisabled || confirmDisabled" />
  36. </template>
  37. <template slot="chargeStatus">
  38. <el-switch v-model="form.chargeStatus" active-text="是" inactive-text="否" :active-value="1"
  39. :inactive-value="0" :disabled="disabled || checkDisabled || confirmDisabled" @change="chargeStatusChange">
  40. </el-switch>
  41. </template>
  42. <template slot="handingUser">
  43. <el-select v-model="form.handingUser" filterable clearable size="small" placeholder="请选择" :disabled="
  44. disabled ||
  45. checkDisabled ||
  46. confirmDisabled
  47. " @change="handingUserChange">
  48. <el-option v-for="(item, index) in userList" :key="index" :label="item.realName" :value="item.id">
  49. </el-option>
  50. </el-select>
  51. </template>
  52. <template slot="handingUserName">
  53. <el-select v-model="form.handingUserName" filterable clearable allow-create default-first-option
  54. size="small" placeholder="请选择" :disabled="
  55. disabled ||
  56. checkDisabled ||
  57. form.chargeStatus == 0 ||
  58. confirmDisabled
  59. ">
  60. <el-option v-for="(item, index) in userList" :key="index" :label="item.realName" :value="item.realName">
  61. </el-option>
  62. </el-select>
  63. </template>
  64. <template slot="external">
  65. <el-switch v-model="form.external" active-text="是" inactive-text="否" :active-value="1" :inactive-value="0"
  66. :disabled="disabled || checkDisabled || confirmDisabled" @change="externalChange"></el-switch>
  67. </template>
  68. </avue-form>
  69. </basic-container>
  70. <containerTitle title="详情内容" />
  71. <basic-container>
  72. <avue-crud ref="crud" :data="dataList" :option="tableOption" :cell-style="cellStyle" @saveColumn="saveColumn"
  73. @resetColumn="resetColumn">
  74. <template slot="menuLeft">
  75. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newDetails"
  76. :disabled="disabled || checkDisabled || confirmDisabled">录入明细</el-button>
  77. <el-button type="info" icon="el-icon-printer" size="small" @click="openReport">报表打印</el-button>
  78. </template>
  79. <template slot="menu" slot-scope="{ row, index }">
  80. <el-button size="small" icon="el-icon-edit" type="text" @click="rowCell(row, index)"
  81. :disabled="disabled || checkDisabled || confirmDisabled">{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
  82. <el-button size="small" icon="el-icon-upload" type="text"
  83. :disabled="disabled || checkDisabled || confirmDisabled" @click="annexOpen(row, index)">附件</el-button>
  84. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)"
  85. :disabled="disabled || checkDisabled || confirmDisabled">删除</el-button>
  86. </template>
  87. <template slot="quantity" slot-scope="{ row, index }">
  88. <el-input-number v-if="row.$cellEdit" v-model="row.quantity" size="small" :controls="false" :precision="0"
  89. style="width: 100%" placeholder="数量"></el-input-number>
  90. <span v-else>{{ row.quantity }}</span>
  91. </template>
  92. <template slot-scope="{ row, index }" slot="unit">
  93. <el-select v-if="row.$cellEdit" v-model="row.unit" size="small" clearable filterable>
  94. <el-option v-for="(item, index) in unitOption" :key="index" :label="item.dictValue"
  95. :value="item.dictValue" />
  96. </el-select>
  97. <span v-else>{{ row.unit }}</span>
  98. </template>
  99. <template slot="amount" slot-scope="{ row, index }">
  100. <el-input-number v-if="row.$cellEdit" v-model="row.amount" size="small" :controls="false" :precision="2"
  101. style="width: 100%" placeholder="金额"></el-input-number>
  102. <span v-else>{{ row.amount }}</span>
  103. </template>
  104. </avue-crud>
  105. </basic-container>
  106. <containerTitle title="客户未收款" />
  107. <basic-container>
  108. <avue-form ref="detailForm" class="trading-form" v-model="form" :option="detailOption"></avue-form>
  109. </basic-container>
  110. </div>
  111. <el-dialog append-to-body title="审批" class="el-dialogDeep" :visible.sync="checkDialog" width="50%"
  112. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
  113. <check :checkData="checkData" :checkDetail="false" :idList="[]" @choceCheckFun="choceCheckFun" />
  114. </el-dialog>
  115. <el-dialog append-to-body title="审批进度" class="el-dialogDeep" :visible.sync="checkScheduleDialog" width="40%"
  116. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
  117. <check-schedule :checkId="checkId" :batchNo="batchNo" @choceScheduleFun="choceScheduleFun" />
  118. </el-dialog>
  119. <!-- 报表-->
  120. <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="交接单" @onClose="onClose()" />
  121. <el-dialog title="附件" :visible.sync="dialogVisible" append-to-body width="70%">
  122. <c-upload typeUpload="PC" :basic="true" deleteUrl="/api/blade-client/common-file/remove" :data="orderList"
  123. :disabled="upLoadForm.status >= 2" :enumerationValue="124"></c-upload>
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="dialogVisible = false" size="small">取 消</el-button>
  126. <el-button type="primary" @click="saveAnnex" size="small" :disabled="upLoadForm.status >= 2">保 存</el-button>
  127. </span>
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. import tableOption from "./config/customerContact.json";
  133. import {
  134. isDiscount,
  135. isPercentage,
  136. micrometerFormat,
  137. IntegerFormat
  138. } from "@/util/validate";
  139. import { gainUser } from "@/api/basicData/customerInquiry";
  140. import { getUserInfo } from "@/api/system/user";
  141. import { getDeptTree } from "@/api/system/dept";
  142. import { getCurrentDate } from "@/util/date";
  143. import { contrastObj, contrastList } from "@/util/contrastData";
  144. import check from "@/components/check/check";
  145. import checkSchedule from "@/components/check/checkSchedule";
  146. import {
  147. dataDetail,
  148. typeSave,
  149. removeGoods,
  150. pleaseCheck,
  151. saveAttached,
  152. getAttachment,
  153. submitConfirm
  154. } from "@/api/standAlone/handoverSheet";
  155. import reportDialog from "@/components/report-dialog/main";
  156. export default {
  157. name: "detail",
  158. props: {
  159. detailData: {
  160. type: Object
  161. }
  162. },
  163. components: {
  164. check,
  165. checkSchedule,
  166. reportDialog
  167. },
  168. data() {
  169. const validateHandingUser = (rule, value, callback) => {
  170. if (this.form.chargeStatus == 1 && !this.form.handingUser) {
  171. callback(new Error("接收人不能为空"));
  172. } else {
  173. callback();
  174. }
  175. };
  176. return {
  177. disabled: false,
  178. pageLoading: false,
  179. btnLoading: false,
  180. form: {},
  181. option: {
  182. menuBtn: false,
  183. labelWidth: 100,
  184. column: [
  185. {
  186. label: "客户名称",
  187. prop: "corpId",
  188. rules: [
  189. {
  190. required: true,
  191. message: " ",
  192. trigger: "change"
  193. }
  194. ],
  195. span: 8,
  196. slot: true
  197. },
  198. {
  199. label: "交接日期",
  200. prop: "handoverDate",
  201. span: 8,
  202. type: "date",
  203. format: "yyyy-MM-dd",
  204. valueFormat: "yyyy-MM-dd HH:mm:ss",
  205. rules: [
  206. {
  207. required: true,
  208. message: " ",
  209. trigger: "blur"
  210. }
  211. ]
  212. },
  213. {
  214. label: "NO.",
  215. prop: "serialNo",
  216. disabled: true,
  217. span: 8
  218. },
  219. {
  220. label: "交接人",
  221. prop: "handoverUserName",
  222. span: 8
  223. },
  224. {
  225. label: "联系电话",
  226. prop: "contacts",
  227. span: 8
  228. },
  229. {
  230. label: "是否收费",
  231. prop: "chargeStatus",
  232. span: 8
  233. },
  234. {
  235. label: "接收人",
  236. prop: "handingUser",
  237. span: 8,
  238. rules: [
  239. {
  240. required: true,
  241. message: " ",
  242. trigger: "change"
  243. }
  244. ],
  245. },
  246. {
  247. label: "是否外部交接单",
  248. prop: "external",
  249. span: 8
  250. },
  251. {
  252. label: "接收客户名称",
  253. prop: "handingCorpName",
  254. span: 8,
  255. display: false
  256. },
  257. {
  258. label: "交接备注",
  259. prop: "remarks",
  260. type: "textarea",
  261. minRows: 2,
  262. span: 24
  263. }
  264. ]
  265. },
  266. detailForm: {},
  267. detailOption: {
  268. menuBtn: false,
  269. labelWidth: 100,
  270. column: [
  271. {
  272. label: "客户名称",
  273. prop: "corpName",
  274. disabled: true,
  275. span: 8
  276. },
  277. {
  278. label: "未收金额",
  279. prop: "uncollectedAmount",
  280. disabled: true,
  281. span: 8
  282. }
  283. ]
  284. },
  285. dataList: [],
  286. tableOption: {},
  287. goodsoptions: [],
  288. unitOption: [],
  289. selectionList: [],
  290. search: {},
  291. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  292. goodsOption: {},
  293. loading: false,
  294. switchDialog: false, // 报表弹窗控制
  295. userList: [],
  296. dic: [],
  297. loginUser: "", // 登录人
  298. oldForm: {},
  299. oldDataList: [],
  300. checkDisabled: false, // 审核状态
  301. confirmDisabled: false, // 提交状态
  302. checker: false,
  303. checkId: "",
  304. batchNo: "",
  305. checkDialog: false,
  306. checkScheduleDialog: false,
  307. checkData: {},
  308. dialogVisible: false,
  309. orderList: [],
  310. upLoadForm: {},
  311. rowIndex: null //暂存明细下标
  312. };
  313. },
  314. async created() {
  315. this.$set(this.form, "handoverDate", getCurrentDate()); // 默认当前日期
  316. this.tableOption = await this.getColumnData(
  317. this.getColumnName(104),
  318. tableOption
  319. );
  320. gainUser().then(res => {
  321. this.userList = res.data.data;
  322. });
  323. getUserInfo().then(res => {
  324. this.loginUser = res.data.data.id;
  325. });
  326. getDeptTree().then(res => {
  327. this.dic = res.data.data;
  328. });
  329. this.getWorkDicts("unit").then(res => {
  330. this.unitOption = res.data.data;
  331. });
  332. if (this.detailData.query) {
  333. this.disabled = true;
  334. this.option.column.map(e => {
  335. this.$set(e, "disabled", true);
  336. });
  337. this.queryData(this.detailData.id);
  338. } else if (this.detailData.auditId) {
  339. this.checker = true;
  340. this.batchNo = this.detailData.check.batchNo;
  341. this.queryData(this.detailData.id);
  342. }
  343. },
  344. filters: {
  345. IntegerFormat(num) {
  346. return IntegerFormat(num);
  347. },
  348. decimalFormat(num) {
  349. return num ? Number(num).toFixed(2) : "0.00";
  350. }
  351. },
  352. methods: {
  353. // 查询
  354. queryData(id) {
  355. this.pageLoading = true;
  356. dataDetail({ id: id })
  357. .then(res => {
  358. this.form = res.data.data;
  359. this.dataList = this.form.itemList ? this.form.itemList : [];
  360. delete this.form.itemList;
  361. this.oldForm = this.deepClone({ ...this.form });
  362. this.oldDataList = this.deepClone([...this.dataList]);
  363. this.checkDisabled = this.form.status > 0 ? true : false;
  364. this.confirmDisabled = this.form.confirmStatus === 1 ? true : false;
  365. if (this.form.status > 0 || this.form.confirmStatus === 1) {
  366. this.option.column.map(e => {
  367. this.$set(e, "disabled", true);
  368. });
  369. }
  370. })
  371. .finally(() => {
  372. this.pageLoading = false;
  373. });
  374. },
  375. //返回列表
  376. backToList() {
  377. this.$emit("goBack");
  378. },
  379. // 编辑按钮触发
  380. openEdit() {
  381. this.disabled = false;
  382. this.option.column.map(e => {
  383. if (this.checkDisabled || this.confirmDisabled) {
  384. this.$set(e, "disabled", true);
  385. } else {
  386. if (e.prop != "serialNo") {
  387. this.$set(e, "disabled", false);
  388. }
  389. }
  390. });
  391. },
  392. // 复制
  393. copyDoc() {
  394. this.$emit("copyOrder", this.form.id);
  395. },
  396. //修改提交触发
  397. editCustomer(status) {
  398. this.$refs["form"].validate((valid, done) => {
  399. done();
  400. if (valid) {
  401. this.$set(this.form, "itemList", this.dataList);
  402. this.form.itemList.forEach(item => {
  403. item.fileList = item.fileList ? item.fileList : [];
  404. });
  405. this.btnLoading = true;
  406. typeSave(this.form)
  407. .then(res => {
  408. this.$message({
  409. type: "success",
  410. message: this.form.id ? "修改成功!" : "新增成功!"
  411. });
  412. this.queryData(res.data.data);
  413. })
  414. .finally(() => {
  415. this.btnLoading = false;
  416. });
  417. } else {
  418. return false;
  419. }
  420. });
  421. },
  422. cellStyle() {
  423. return "padding:0;height:40px;";
  424. },
  425. async saveColumn() {
  426. const inSave = await this.saveColumnData(
  427. this.getColumnName(104),
  428. this.tableOption
  429. );
  430. if (inSave) {
  431. this.$message.success("保存成功");
  432. //关闭窗口
  433. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  434. this.$nextTick(() => {
  435. this.$refs.crud.doLayout();
  436. });
  437. }
  438. },
  439. async resetColumn() {
  440. this.tableOption = tableOption;
  441. const inSave = await this.delColumnData(
  442. this.getColumnName(104),
  443. tableOption
  444. );
  445. if (inSave) {
  446. this.$nextTick(() => {
  447. this.$refs.crud.doLayout();
  448. });
  449. this.$message.success("重置成功");
  450. //关闭窗口
  451. setTimeout(() => {
  452. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  453. }, 1000);
  454. }
  455. },
  456. //录入明细
  457. newDetails() {
  458. this.$refs["form"].validate((valid, done) => {
  459. done();
  460. if (valid) {
  461. this.dataList.push({
  462. $cellEdit: true
  463. });
  464. }
  465. });
  466. },
  467. rowCell(row, index) {
  468. if (row.$cellEdit == true) {
  469. this.$set(row, "$cellEdit", false);
  470. } else {
  471. this.$set(row, "$cellEdit", true);
  472. }
  473. },
  474. rowDel(row, index) {
  475. this.$confirm("确定删除数据?", {
  476. confirmButtonText: "确定",
  477. cancelButtonText: "取消",
  478. type: "warning"
  479. }).then(() => {
  480. if (row.id) {
  481. removeGoods(row.id).then(res => {
  482. this.$message({
  483. type: "success",
  484. message: "删除成功!"
  485. });
  486. this.dataList.splice(row.$index, 1);
  487. });
  488. } else {
  489. this.$message({
  490. type: "success",
  491. message: "删除成功!"
  492. });
  493. this.dataList.splice(row.$index, 1);
  494. }
  495. });
  496. },
  497. getKHData(row) {
  498. this.$set(this.form, "corpName", row.cname);
  499. },
  500. // 验证新旧值对比
  501. verification() {
  502. if (
  503. contrastObj(this.form, this.oldForm) ||
  504. contrastList(this.dataList, this.oldDataList)
  505. ) {
  506. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  507. confirmButtonText: "确定",
  508. cancelButtonText: "取消",
  509. type: "warning"
  510. })
  511. .then(() => {
  512. this.editCustomer();
  513. })
  514. .catch(() => {
  515. return false; //取消改动数据
  516. });
  517. } else {
  518. return true;
  519. }
  520. },
  521. //打开审核
  522. openCheckDialog() {
  523. this.checkData = this.detailData.check;
  524. this.checkDialog = true;
  525. },
  526. //关闭审核
  527. choceCheckFun() {
  528. this.checkDialog = false;
  529. },
  530. choceScheduleFun() {
  531. this.checkScheduleDialog = false;
  532. },
  533. // 请核
  534. pleaseCheck() {
  535. if (this.verification()) {
  536. const data = {
  537. id: this.form.id,
  538. serialNo: this.form.serialNo,
  539. checkType: "jjd",
  540. url: "/workManagement/handoverSheet/index",
  541. pageStatus: "this.$store.getters.handOverStatus",
  542. pageLabel: "交接单",
  543. checkFlag: 1
  544. };
  545. this.btnLoading = true;
  546. pleaseCheck(data)
  547. .then(res => {
  548. this.$message.success("请核成功");
  549. this.queryData(this.form.id);
  550. })
  551. .catch(() => {
  552. this.$message.error("请核失败");
  553. })
  554. .finally(() => {
  555. this.btnLoading = false;
  556. });
  557. }
  558. },
  559. // 报表
  560. openReport() {
  561. this.switchDialog = !this.switchDialog;
  562. },
  563. // 报表关闭
  564. onClose(val) {
  565. this.switchDialog = val;
  566. },
  567. //打开附件
  568. annexOpen(row, index) {
  569. this.dialogVisible = true;
  570. this.upLoadForm = row;
  571. if (row.id) {
  572. getAttachment({ id: row.id }).then(res => {
  573. this.orderList = res.data.data ? res.data.data : [];
  574. });
  575. } else {
  576. this.$set(row, "fileList", row.fileList ? row.fileList : []); // 新数据默认插入空
  577. this.orderList = [...row.fileList];
  578. this.rowIndex = index;
  579. }
  580. },
  581. //保存
  582. saveAnnex() {
  583. if (this.upLoadForm.id) {
  584. this.orderList.forEach(item =>
  585. this.$set(item, "pid", this.upLoadForm.id)
  586. );
  587. saveAttached(this.orderList).then(res => {
  588. this.$nextTick(() => {
  589. this.dialogVisible = false;
  590. this.rowIndex = null;
  591. this.orderList = [];
  592. });
  593. });
  594. } else {
  595. this.dataList[this.rowIndex].fileList = [...this.orderList];
  596. this.$nextTick(() => {
  597. this.dialogVisible = false;
  598. this.rowIndex = null;
  599. this.orderList = [];
  600. });
  601. }
  602. },
  603. // 是否收费选择触发
  604. chargeStatusChange(data) {
  605. if (data === 0) this.form.handingUser = null;
  606. },
  607. // 接收人选择触发
  608. handingUserChange(data) {
  609. this.$set(
  610. this.form,
  611. "handingUserName",
  612. this.userList.find(item => data == item.id)
  613. ? this.userList.find(item => data == item.id).realName
  614. : null
  615. );
  616. },
  617. // 提交确认
  618. submitConfirm() {
  619. if (this.verification()) {
  620. this.$confirm("提交确认?", "提示", {
  621. confirmButtonText: "确定",
  622. cancelButtonText: "取消",
  623. type: "warning"
  624. }).then(() => {
  625. this.btnLoading = true;
  626. submitConfirm({ id: this.form.id })
  627. .then(res => {
  628. this.$message.success("提交成功");
  629. this.queryData(this.form.id);
  630. })
  631. .finally(() => {
  632. this.btnLoading = false;
  633. });
  634. });
  635. }
  636. },
  637. externalChange(row) {
  638. // if (row == 1) {
  639. // this.findObject(this.option.column, "handingCorpName").display = true;
  640. // } else {
  641. // this.findObject(this.option.column, "handingCorpName").display = false;
  642. // }
  643. }
  644. },
  645. watch: {
  646. "form.external": function (obj) {
  647. if (obj == 1) {
  648. this.findObject(this.option.column, "handingCorpName").display = true;
  649. } else {
  650. this.findObject(this.option.column, "handingCorpName").display = false;
  651. }
  652. }
  653. }
  654. };
  655. </script>
  656. <style scoped>
  657. </style>