detail.vue 14 KB

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