detailsPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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"
  21. :props="props">
  22. </avue-input-tree>
  23. <i class="el-icon-setting" 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"
  84. width="80%" append-to-body @closed="corpTypeClosed">
  85. <span>
  86. <supplier-type></supplier-type>
  87. </span>
  88. <div class="avue-dialog__footer">
  89. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  90. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  91. </div>
  92. </el-dialog>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. import { option2, option3 } from "./js/optionList";
  98. import { getDetails, addCorpType, getCorpType, submit, customerList,itemDel } from "@/api/basicData/client";
  99. import supplierType from '@/components/supplierType/index'
  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. data2: [],
  120. option: {
  121. menuBtn: false,
  122. labelWidth: 130,
  123. column: [
  124. {
  125. label: "供应商名称",
  126. prop: "cname",
  127. rules: [
  128. {
  129. required: true,
  130. message: "",
  131. trigger: "blur"
  132. }
  133. ],
  134. span: 8,
  135. },
  136. {
  137. label: "供应商分类",
  138. prop: "corpsTypeId",
  139. span: 8,
  140. },
  141. {
  142. label: "期初欠款",
  143. prop: "arrears",
  144. span: 8,
  145. },
  146. {
  147. label: "电话",
  148. prop: "tel",
  149. span: 8,
  150. },
  151. {
  152. label: "备用电话",
  153. prop: "telephone",
  154. span: 8,
  155. },
  156. {
  157. label: "传真",
  158. prop: "fax",
  159. span: 8,
  160. },
  161. {
  162. label: "邮箱",
  163. prop: "mailbox",
  164. span: 8,
  165. },
  166. {
  167. label: "备注",
  168. prop: "remarks",
  169. type: "textarea",
  170. minRows: 2,
  171. span: 24,
  172. }
  173. ]
  174. },
  175. option2: {},
  176. option3: {},
  177. option4: {
  178. menuBtn: false,
  179. labelWidth: 80,
  180. column: [
  181. {
  182. label: "分类名称",
  183. prop: "cname",
  184. rules: [
  185. {
  186. required: true,
  187. message: "",
  188. trigger: "blur"
  189. }
  190. ],
  191. span: 24,
  192. },
  193. {
  194. label: "上级类型",
  195. prop: "parentId",
  196. dicData: [],
  197. type: "tree",
  198. props: {
  199. label: "cname",
  200. value: "id"
  201. },
  202. span: 24,
  203. }
  204. ]
  205. },
  206. corpsFiles: []
  207. };
  208. },
  209. props: {
  210. detailData: {
  211. type: Object
  212. }
  213. },
  214. components: {
  215. supplierType
  216. },
  217. async created() {
  218. this.option2 = await this.getColumnData(this.getColumnName(210), option2);
  219. // this.option3 = await this.getColumnData(this.getColumnName(210.4), option3);
  220. if (this.detailData.id) {
  221. this.getDetail(this.detailData.id);
  222. }
  223. if (this.detailData.status == 1) {
  224. this.option.disabled = true;
  225. }
  226. this.getCorpType()
  227. this.getAllWorkDicts()
  228. },
  229. methods: {
  230. getAllWorkDicts() {
  231. customerList({ corpType: "GYS" }).then(res => {
  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. this.loadingBtn = true;
  350. submit({ ...this.form, code: this.form.cname, corpType: "GYS", corpsAddrList: this.data.concat(this.data2) })
  351. .then(res => {
  352. this.$message.success("保存成功");
  353. this.form = res.data.data;
  354. this.data = res.data.data.corpsAddrList
  355. this.corpsFiles = res.data.data.corpsFiles
  356. })
  357. .finally(() => {
  358. this.loadingBtn = false;
  359. });
  360. } else {
  361. return false;
  362. }
  363. });
  364. },
  365. async saveColumn() {
  366. const inSave = await this.saveColumnData(
  367. this.getColumnName(210),
  368. this.option2
  369. );
  370. if (inSave) {
  371. this.$nextTick(() => {
  372. this.$refs.crud.doLayout();
  373. });
  374. this.$message.success("保存成功");
  375. //关闭窗口
  376. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  377. }
  378. },
  379. async resetColumn() {
  380. this.option2 = option2;
  381. const inSave = await this.delColumnData(
  382. this.getColumnName(210),
  383. option2
  384. );
  385. if (inSave) {
  386. this.$nextTick(() => {
  387. this.$refs.crud.doLayout();
  388. });
  389. this.getAllWorkDicts()
  390. this.$message.success("重置成功");
  391. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  392. }
  393. },
  394. async saveColumn2() {
  395. const inSave = await this.saveColumnData(
  396. this.getColumnName(210.4),
  397. this.option3
  398. );
  399. if (inSave) {
  400. this.$nextTick(() => {
  401. this.$refs.crud.doLayout();
  402. });
  403. this.$message.success("保存成功");
  404. //关闭窗口
  405. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  406. }
  407. },
  408. async resetColumn2() {
  409. this.option3 = option3;
  410. const inSave = await this.delColumnData(
  411. this.getColumnName(210.4),
  412. option3
  413. );
  414. if (inSave) {
  415. this.$nextTick(() => {
  416. this.$refs.crud.doLayout();
  417. });
  418. this.getAllWorkDicts()
  419. this.$message.success("重置成功");
  420. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  421. }
  422. },
  423. //返回列表
  424. backToList() {
  425. this.$emit("goBack");
  426. console.log(11111)
  427. }
  428. }
  429. };
  430. </script>
  431. <style lang="scss" scoped>
  432. .trading-form ::v-deep .el-form-item {
  433. margin-bottom: 8px !important;
  434. }
  435. // ::v-deep .el-dialog__body {
  436. // padding: 0px 20px 15px 20px;
  437. // }
  438. ::v-deep .el-form-item__error {
  439. display: none !important;
  440. }
  441. .el-dialog ::v-deep .el-form-item__error {
  442. display: none !important;
  443. }
  444. .img-form ::v-deep .el-form-item {
  445. height: 150px;
  446. line-height: 150px;
  447. margin-bottom: 8px !important;
  448. }
  449. .img-form ::v-deep .avue-upload__icon {
  450. font-size: 20px;
  451. width: 150px;
  452. height: 150px;
  453. line-height: 150px;
  454. }
  455. ::v-deep .el-table .cell {
  456. padding: 0 2px !important;
  457. }
  458. ::v-deep .avue-crud .el-table .el-form-item__label {
  459. left: -1px;
  460. }
  461. .addressTabs {
  462. display: flex;
  463. justify-content: center;
  464. span {
  465. width: 100px;
  466. font-size: 18px;
  467. font-weight: 600;
  468. text-align: center;
  469. }
  470. }
  471. </style>