detailsPage.vue 14 KB

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