detailsPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button type="primary" size="small" @click="editCustomer">
  12. 保存数据
  13. </el-button>
  14. </div>
  15. </div>
  16. <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
  17. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  18. <template slot="corpsTypeId">
  19. <div style="display:flex;">
  20. <avue-input-tree default-expand-all v-model="form.corpsTypeId"
  21. placeholder="请选择客户分类" :dic="corpTypeList" :props="props">
  22. </avue-input-tree>
  23. <i class="el-icon-circle-plus-outline" style="font-size:18px;line-height: 32px;margin-left:4px"
  24. @click="corpTypeVisible = true"></i>
  25. </div>
  26. </template>
  27. </avue-form>
  28. </trade-card>
  29. <trade-card title="地址管理" v-loading="loadingBtn">
  30. <avue-crud ref="crud" :option="option2" :data="data" :table-loading="loading" @saveColumn="saveColumn"
  31. @resetColumn="resetColumn" :cell-style="cellStyle" class="address">
  32. <template slot="headerSerial">
  33. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  34. :disabled="detailData.status == 1" circle></el-button>
  35. </template>
  36. <template slot="menu" slot-scope="{ row, index }">
  37. <el-button size="small" type="text" @click="rowCell(row, index)">{{
  38. row.$cellEdit ? "保存" : "修改"
  39. }}</el-button>
  40. <el-button size="small" type="text" @click="rowDel(row, index)">删除
  41. </el-button>
  42. </template>
  43. </avue-crud>
  44. <!-- <el-tabs v-model="activeName">
  45. <el-tab-pane label="客户地址" name="first">
  46. <avue-crud ref="crud" :option="option2" :data="data1" :table-loading="loading" @saveColumn="saveColumn"
  47. @resetColumn="resetColumn" :cell-style="cellStyle" class="address">
  48. <template slot="headerSerial">
  49. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  50. :disabled="detailData.status == 1" circle></el-button>
  51. </template>
  52. <template slot="menu" slot-scope="{ row, index }">
  53. <el-button size="small" type="text" @click="rowCell(row, index)">{{
  54. row.$cellEdit ? "保存" : "修改"
  55. }}</el-button>
  56. <el-button size="small" type="text" @click="rowDel(row, index)">删除
  57. </el-button>
  58. </template>
  59. </avue-crud>
  60. </el-tab-pane>
  61. <el-tab-pane label="物流地址" name="second">
  62. <avue-crud ref="crud2" :option="option3" :data="data2" :table-loading="loading" @saveColumn="saveColumn2"
  63. @resetColumn="resetColumn2" :cell-style="cellStyle">
  64. <template slot="headerSerial">
  65. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow2"
  66. :disabled="detailData.status == 1" circle></el-button>
  67. </template>
  68. <template slot="menu" slot-scope="{ row, index }">
  69. <el-button size="small" type="text" @click="rowCell2(row, index)">{{
  70. row.$cellEdit ? "保存" : "修改"
  71. }}</el-button>
  72. <el-button size="small" type="text" @click="rowDel2(row, index)">删除
  73. </el-button>
  74. </template>
  75. </avue-crud>
  76. </el-tab-pane>
  77. </el-tabs> -->
  78. </trade-card>
  79. <containerTitle title="上传附件"></containerTitle>
  80. <c-upload v-loading="loadingBtn" typeUpload="CD"
  81. deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="corpsFiles" display
  82. :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>
  83. <el-dialog title="添加客户分类" v-dialogDrag :visible.sync="corpTypeVisible" class="avue-dialog avue-dialog--top"
  84. width="30%" append-to-body @closed="corpTypeClosed">
  85. <span>
  86. <avue-form :key="reload" ref="corpType" v-model="form4" :option="option4" style="margin-top:20px">
  87. </avue-form>
  88. </span>
  89. <div class="avue-dialog__footer">
  90. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  91. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import { option2, option3 } from "./js/optionList";
  99. import { getDetails, addCorpType, getCorpType, submit, customerList } from "@/api/basicData/client";
  100. export default {
  101. name: "index",
  102. data() {
  103. return {
  104. props: {
  105. label: 'title',
  106. value: 'value'
  107. },
  108. corpTypeList: [],
  109. corpTypeVisible: false,
  110. activeName: 'first',
  111. loadingBtn: false,
  112. addressTitle: null,
  113. addressVisible: false,
  114. form: {},
  115. form2: {},
  116. form3: {},
  117. form4: {},
  118. data:[],
  119. data1: [],
  120. data2: [],
  121. option: {
  122. menuBtn: false,
  123. labelWidth: 130,
  124. column: [
  125. {
  126. label: "客户名称",
  127. prop: "cname",
  128. rules: [
  129. {
  130. required: true,
  131. message: "",
  132. trigger: "blur"
  133. }
  134. ],
  135. span: 8,
  136. },
  137. {
  138. label: "客户分类",
  139. prop: "corpsTypeId",
  140. span: 8,
  141. },
  142. {
  143. label: "期初欠款",
  144. prop: "arrears",
  145. span: 8,
  146. },
  147. {
  148. label: "电话",
  149. prop: "tel",
  150. span: 8,
  151. },
  152. {
  153. label: "备用电话",
  154. prop: "telephone",
  155. span: 8,
  156. },
  157. {
  158. label: "传真",
  159. prop: "fax",
  160. span: 8,
  161. },
  162. {
  163. label: "邮箱",
  164. prop: "mailbox",
  165. span: 8,
  166. },
  167. {
  168. label: "备注",
  169. prop: "remarks",
  170. type: "textarea",
  171. minRows: 2,
  172. span: 24,
  173. }
  174. ]
  175. },
  176. option2: {},
  177. option3: {},
  178. option4: {
  179. menuBtn: false,
  180. labelWidth: 80,
  181. column: [
  182. {
  183. label: "分类名称",
  184. prop: "cname",
  185. rules: [
  186. {
  187. required: true,
  188. message: "",
  189. trigger: "blur"
  190. }
  191. ],
  192. span: 24,
  193. },
  194. {
  195. label: "上级类型",
  196. prop: "parentId",
  197. dicData: [],
  198. type: "tree",
  199. props: {
  200. label: "cname",
  201. value: "id"
  202. },
  203. span: 24,
  204. }
  205. ]
  206. },
  207. corpsFiles:[]
  208. };
  209. },
  210. props: {
  211. detailData: {
  212. type: Object
  213. }
  214. },
  215. async created() {
  216. this.option2 = await this.getColumnData(this.getColumnName(208), option2);
  217. // this.option3 = await this.getColumnData(this.getColumnName(208.4), option3);
  218. // if (this.detailData.id) {
  219. // this.getDetail(this.detailData.id);
  220. // }
  221. if (this.detailData.status == 1) {
  222. this.option.disabled = true;
  223. }
  224. this.getCorpType()
  225. this.getAllWorkDicts()
  226. },
  227. methods: {
  228. getAllWorkDicts() {
  229. customerList({ corpType: "KH" }).then(res => {
  230. this.findObject(this.option4.column, "parentId").dicData = res.data.data.records
  231. });
  232. // this.getWorkDicts("abbreviation").then(res => {
  233. // this.findObject(this.option2.column, "abbreviation").dicData = res.data.data;
  234. // });
  235. // this.$refs.crud.init();
  236. },
  237. cellStyle() {
  238. return "padding:0;height:40px;";
  239. },
  240. selectValue(value, row) {
  241. if (row.feesId) {
  242. row.feesName = value.cname
  243. } else {
  244. row.feesName = ""
  245. }
  246. },
  247. getDetail(id) {
  248. this.loadingBtn = true
  249. getDetails({ id: id })
  250. .then(res => {
  251. this.form = res.data.data;
  252. this.data= res.data.data.corpsAddrList
  253. this.corpsFiles=res.data.data.corpsFiles
  254. })
  255. .finally(() => {
  256. this.loadingBtn = false;
  257. });
  258. },
  259. getCorpData(row) {
  260. this.form.corpName = row.cname
  261. },
  262. addRow() {
  263. this.data.push({ $cellEdit: true})
  264. },
  265. rowCell(row, index) {
  266. if (row.$cellEdit == true) {
  267. this.$set(row, "$cellEdit", false);
  268. } else {
  269. this.$set(row, "$cellEdit", true);
  270. }
  271. },
  272. rowDel(row, index) {
  273. this.$confirm("确定删除数据?", {
  274. confirmButtonText: "确定",
  275. cancelButtonText: "取消",
  276. type: "warning"
  277. }).then(() => {
  278. if (row.id) {
  279. // itemDel(row.id).then(res => {
  280. // this.$message({
  281. // type: "success",
  282. // message: "删除成功!"
  283. // });
  284. // this.data1.splice(index, 1);
  285. // });
  286. } else {
  287. this.$message({
  288. type: "success",
  289. message: "删除成功!"
  290. });
  291. this.data.splice(index, 1);
  292. }
  293. });
  294. },
  295. addRow2() {
  296. this.data2.push({ $cellEdit: true, type: 1 })
  297. },
  298. rowCell2(row, index) {
  299. if (row.$cellEdit == true) {
  300. this.$set(row, "$cellEdit", false);
  301. } else {
  302. this.$set(row, "$cellEdit", true);
  303. }
  304. },
  305. rowDe2(row, index) {
  306. this.$confirm("确定删除数据?", {
  307. confirmButtonText: "确定",
  308. cancelButtonText: "取消",
  309. type: "warning"
  310. }).then(() => {
  311. if (row.id) {
  312. // itemDel(row.id).then(res => {
  313. // this.$message({
  314. // type: "success",
  315. // message: "删除成功!"
  316. // });
  317. // this.data2.splice(index, 1);
  318. // });
  319. } else {
  320. this.$message({
  321. type: "success",
  322. message: "删除成功!"
  323. });
  324. this.data2.splice(index, 1);
  325. }
  326. });
  327. },
  328. corpTypeClosed() {
  329. this.reload = Math.random();
  330. this.form4 = this.$options.data().form4
  331. },
  332. getCorpType() {
  333. getCorpType({ corpType: 'KH' }).then(res => {
  334. this.corpTypeList = res.data.data
  335. })
  336. },
  337. addCorpType() {
  338. this.$refs["corpType"].validate((valid, done) => {
  339. done();
  340. if (valid) {
  341. addCorpType({ ...this.form4, corpType: 'KH', status: 0 })
  342. .then(res => {
  343. this.$message.success("保存成功");
  344. this.getCorpType()
  345. this.corpTypeVisible = false
  346. })
  347. } else {
  348. return false;
  349. }
  350. });
  351. },
  352. //修改提交触发
  353. editCustomer() {
  354. this.$refs["form"].validate((valid, done) => {
  355. done();
  356. if (valid) {
  357. this.loadingBtn = true;
  358. submit({ ...this.form, code: this.form.cname, corpType: "KH", corpsAddrList: this.data})
  359. .then(res => {
  360. this.$message.success("保存成功");
  361. this.form = res.data.data;
  362. this.data = res.data.data.corpsAddrList
  363. this.corpsFiles=res.data.data.corpsFiles
  364. })
  365. .finally(() => {
  366. this.loadingBtn = false;
  367. });
  368. } else {
  369. return false;
  370. }
  371. });
  372. },
  373. async saveColumn() {
  374. const inSave = await this.saveColumnData(
  375. this.getColumnName(208),
  376. this.option2
  377. );
  378. if (inSave) {
  379. this.$nextTick(() => {
  380. this.$refs.crud.doLayout();
  381. });
  382. this.$message.success("保存成功");
  383. //关闭窗口
  384. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  385. }
  386. },
  387. async resetColumn() {
  388. this.option2 = option2;
  389. const inSave = await this.delColumnData(
  390. this.getColumnName(208),
  391. option2
  392. );
  393. if (inSave) {
  394. this.$nextTick(() => {
  395. this.$refs.crud.doLayout();
  396. });
  397. this.getAllWorkDicts()
  398. this.$message.success("重置成功");
  399. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  400. }
  401. },
  402. async saveColumn2() {
  403. const inSave = await this.saveColumnData(
  404. this.getColumnName(208.4),
  405. this.option3
  406. );
  407. if (inSave) {
  408. this.$nextTick(() => {
  409. this.$refs.crud.doLayout();
  410. });
  411. this.$message.success("保存成功");
  412. //关闭窗口
  413. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  414. }
  415. },
  416. async resetColumn2() {
  417. this.option3 = option3;
  418. const inSave = await this.delColumnData(
  419. this.getColumnName(208.4),
  420. option3
  421. );
  422. if (inSave) {
  423. this.$nextTick(() => {
  424. this.$refs.crud.doLayout();
  425. });
  426. this.getAllWorkDicts()
  427. this.$message.success("重置成功");
  428. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  429. }
  430. },
  431. //返回列表
  432. backToList() {
  433. this.$emit("goBack");
  434. console.log(11111)
  435. }
  436. }
  437. };
  438. </script>
  439. <style lang="scss" scoped>
  440. .trading-form ::v-deep .el-form-item {
  441. margin-bottom: 8px !important;
  442. }
  443. ::v-deep .el-dialog__body {
  444. padding: 0px 20px 15px 20px;
  445. }
  446. ::v-deep .el-form-item__error {
  447. display: none !important;
  448. }
  449. .el-dialog ::v-deep .el-form-item__error {
  450. display: none !important;
  451. }
  452. .img-form ::v-deep .el-form-item {
  453. height: 150px;
  454. line-height: 150px;
  455. margin-bottom: 8px !important;
  456. }
  457. .img-form ::v-deep .avue-upload__icon {
  458. font-size: 20px;
  459. width: 150px;
  460. height: 150px;
  461. line-height: 150px;
  462. }
  463. ::v-deep .el-table .cell {
  464. padding: 0 2px !important;
  465. }
  466. ::v-deep .avue-crud .el-table .el-form-item__label {
  467. left: -1px;
  468. }
  469. .addressTabs {
  470. display: flex;
  471. justify-content: center;
  472. span {
  473. width: 100px;
  474. font-size: 18px;
  475. font-weight: 600;
  476. text-align: center;
  477. }
  478. }
  479. </style>