detailsPage.vue 13 KB

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