detail.vue 16 KB

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