detailsPage.vue 14 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-input-tree default-expand-all v-model="form.corpsTypeId" placeholder="请选择供应商分类" :dic="corpTypeList"
  21. :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. <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="corpsFiles" 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. corpsFiles: []
  193. };
  194. },
  195. props: {
  196. detailData: {
  197. type: Object
  198. }
  199. },
  200. async created() {
  201. this.option2 = await this.getColumnData(this.getColumnName(210), option2);
  202. this.option3 = await this.getColumnData(this.getColumnName(210.4), option3);
  203. if (this.detailData.id) {
  204. this.getDetail(this.detailData.id);
  205. }
  206. if (this.detailData.status == 1) {
  207. this.option.disabled = true;
  208. }
  209. this.getCorpType()
  210. this.getAllWorkDicts()
  211. },
  212. methods: {
  213. getAllWorkDicts() {
  214. customerList({ corpType: "GYS" }).then(res => {
  215. this.findObject(this.option4.column, "parentId").dicData = res.data.data.records
  216. });
  217. // this.getWorkDicts("abbreviation").then(res => {
  218. // this.findObject(this.option2.column, "abbreviation").dicData = res.data.data;
  219. // });
  220. this.$refs.crud.init();
  221. },
  222. cellStyle() {
  223. return "padding:0;height:40px;";
  224. },
  225. selectValue(value, row) {
  226. if (row.feesId) {
  227. row.feesName = value.cname
  228. } else {
  229. row.feesName = ""
  230. }
  231. },
  232. getDetail(id) {
  233. this.loadingBtn = true
  234. getDetails({ id: id })
  235. .then(res => {
  236. this.form = res.data.data;
  237. this.data1 = res.data.data.corpsAddrList.filter(e => e.type == 0);
  238. this.data2 = res.data.data.corpsAddrList.filter(e => e.type == 1);
  239. this.corpsFiles = res.data.data.corpsFiles
  240. })
  241. .finally(() => {
  242. this.loadingBtn = false;
  243. });
  244. },
  245. getCorpData(row) {
  246. this.form.corpName = row.cname
  247. },
  248. addRow() {
  249. this.data1.push({ $cellEdit: true, type: 0 })
  250. },
  251. rowCell(row, index) {
  252. if (row.$cellEdit == true) {
  253. this.$set(row, "$cellEdit", false);
  254. } else {
  255. this.$set(row, "$cellEdit", true);
  256. }
  257. },
  258. rowDel(row, index) {
  259. this.$confirm("确定删除数据?", {
  260. confirmButtonText: "确定",
  261. cancelButtonText: "取消",
  262. type: "warning"
  263. }).then(() => {
  264. if (row.id) {
  265. // itemDel(row.id).then(res => {
  266. // this.$message({
  267. // type: "success",
  268. // message: "删除成功!"
  269. // });
  270. // this.data1.splice(index, 1);
  271. // });
  272. } else {
  273. this.$message({
  274. type: "success",
  275. message: "删除成功!"
  276. });
  277. this.data1.splice(index, 1);
  278. }
  279. });
  280. },
  281. addRow2() {
  282. this.data2.push({ $cellEdit: true, type: 1 })
  283. },
  284. rowCell2(row, index) {
  285. if (row.$cellEdit == true) {
  286. this.$set(row, "$cellEdit", false);
  287. } else {
  288. this.$set(row, "$cellEdit", true);
  289. }
  290. },
  291. rowDe2(row, index) {
  292. this.$confirm("确定删除数据?", {
  293. confirmButtonText: "确定",
  294. cancelButtonText: "取消",
  295. type: "warning"
  296. }).then(() => {
  297. if (row.id) {
  298. // itemDel(row.id).then(res => {
  299. // this.$message({
  300. // type: "success",
  301. // message: "删除成功!"
  302. // });
  303. // this.data2.splice(index, 1);
  304. // });
  305. } else {
  306. this.$message({
  307. type: "success",
  308. message: "删除成功!"
  309. });
  310. this.data2.splice(index, 1);
  311. }
  312. });
  313. },
  314. corpTypeClosed() {
  315. this.reload = Math.random();
  316. this.form4 = this.$options.data().form4
  317. },
  318. getCorpType() {
  319. getCorpType({ corpType: 'GYS' }).then(res => {
  320. this.corpTypeList = res.data.data
  321. })
  322. },
  323. addCorpType() {
  324. this.$refs["corpType"].validate((valid, done) => {
  325. done();
  326. if (valid) {
  327. addCorpType({ ...this.form4, corpType: 'GYS', status: 0 })
  328. .then(res => {
  329. this.$message.success("保存成功");
  330. this.getCorpType()
  331. this.corpTypeVisible = false
  332. })
  333. } else {
  334. return false;
  335. }
  336. });
  337. },
  338. //修改提交触发
  339. editCustomer() {
  340. this.$refs["form"].validate((valid, done) => {
  341. done();
  342. if (valid) {
  343. this.loadingBtn = true;
  344. submit({ ...this.form, code: this.form.cname, corpType: "GYS", corpsAddrList: this.data1.concat(this.data2) })
  345. .then(res => {
  346. this.$message.success("保存成功");
  347. this.form = res.data.data;
  348. this.data1 = res.data.data.corpsAddrList.filter(e => e.type == 0);
  349. this.data2 = res.data.data.corpsAddrList.filter(e => e.type == 1);
  350. this.corpsFiles = res.data.data.corpsFiles
  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(210),
  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(210),
  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(210.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(210.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>