detail.vue 13 KB

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