detail.vue 21 KB

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