index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"
  7. @save="corpTypeVisible = true">
  8. <template slot="addBtn">
  9. <i class="el-icon-setting" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"
  10. @click="corpTypeVisible = true"></i>
  11. </template>
  12. </avue-tree>
  13. </el-col>
  14. <el-col :span="20">
  15. <avue-crud
  16. :option="option"
  17. :search.sync="search"
  18. v-model="form"
  19. :table-loading="loading"
  20. :data="dataList"
  21. ref="crud"
  22. :key="key"
  23. @on-load="onLoad"
  24. @search-change="searchChange"
  25. @row-del="rowDel"
  26. @refresh-change="refreshChange"
  27. @resetColumn="resetColumnTwo('crud','option','optionList',262)"
  28. @saveColumn="saveColumnTwo('crud','option','optionList',262)"
  29. :page.sync="page">
  30. <template slot-scope="{type,size,row,index}" slot="menu">
  31. <el-button icon="el-icon-view" :size="size" :type="type" @click="check(row)">查看</el-button>
  32. <el-button icon="el-icon-delete" :size="size" :type="type" @click="$refs.crud.rowDel(row,index)">删除</el-button>
  33. </template>
  34. <template slot="enableOrNot" slot-scope="{row,index,disabled}">
  35. <el-switch
  36. active-value="1"
  37. inactive-value="0"
  38. :disabled="disabled"
  39. v-model="row.enableOrNot">
  40. </el-switch>
  41. </template>
  42. <template slot="corpNameSearch">
  43. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  44. </template>
  45. <template slot="shippingCompanyNameSearch">
  46. <crop-select v-model="search.shippingCompanyId" corpType="KH" :refresh="false"></crop-select>
  47. </template>
  48. <template slot-scope="scope" slot="bookingAgentSearch">
  49. <crop-select v-model="search.bookingAgentId" corpType="KH" :refresh="false"></crop-select>
  50. </template>
  51. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  52. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新增供应商</el-button>
  53. <el-button type="primary" size="small" icon="el-icon-bottom" @click="excelBox = true">导入</el-button>
  54. </template>
  55. </avue-crud>
  56. </el-col>
  57. </el-row>
  58. </basic-container>
  59. <el-dialog title="导入供应商" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  60. v-dialog-drag>
  61. <avue-form :option="excelOption" v-model="excelForm" table-loading="excelLoading"
  62. :upload-before="uploadBefore" :upload-after="uploadAfter">
  63. <template slot="excelTemplate">
  64. <el-button type="primary" @click="derivation">
  65. 点击下载<i class="el-icon-download el-icon--right"></i>
  66. </el-button>
  67. </template>
  68. </avue-form>
  69. <p style="text-align: center;color: #DC0505">
  70. 温馨提示 第一次导入时请先下载模板
  71. </p>
  72. </el-dialog>
  73. <el-dialog title="设置供应商分类" v-dialogDrag :visible.sync="corpTypeVisible" class="avue-dialog" width="80%"
  74. append-to-body @closed="corpTypeClosed">
  75. <span>
  76. <corp-type corpType="GYS"></corp-type>
  77. <!-- <avue-form :key="reload" ref="corpType" v-model="form4" :option="option4" style="margin-top:20px">
  78. </avue-form> -->
  79. </span>
  80. <div class="avue-dialog__footer">
  81. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  82. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  83. </div>
  84. </el-dialog>
  85. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  86. </div>
  87. </template>
  88. <script>
  89. // import {getList, remove} from "@/api/oceanShipping/maritimeExport/index.js";
  90. import detailsPage from "./detailsPage"
  91. import {getToken} from "@/util/auth";
  92. import {getCorpType,getList,remove} from "@/api/tirePartsMall/basicData/customerInformation";
  93. import corpType from "./components/index";
  94. import { option } from "../commodityInformation/js/optionList";
  95. export default {
  96. name: "index",
  97. components: {
  98. corpType,
  99. detailsPage
  100. },
  101. data() {
  102. return {
  103. treeData:[],
  104. corpTypeVisible:false,
  105. treeOption: {
  106. addBtn: false,
  107. menu: false,
  108. size: "small",
  109. props: {
  110. labelText: "标题",
  111. label: "title",
  112. value: "value",
  113. }
  114. },
  115. excelBox:false,
  116. excelForm: {},
  117. excelOption: {
  118. submitBtn: false,
  119. emptyBtn: false,
  120. column: [
  121. {
  122. label: "模板下载",
  123. prop: "excelTemplate",
  124. formslot: true,
  125. span: 24
  126. },
  127. {
  128. label: "模板上传",
  129. prop: "excelFile",
  130. type: "upload",
  131. drag: true,
  132. loadText: "模板上传中,请稍等",
  133. span: 24,
  134. propsHttp: {
  135. res: "data"
  136. },
  137. tip: "请上传 .xls,.xlsx 标准格式文件",
  138. action: "/api/blade-client/corpsdesc/import-desc?corpType=KH"
  139. }
  140. ]
  141. },
  142. detailsOpen: false,
  143. loading: false,
  144. search: {},
  145. form: {},
  146. dataList: [],
  147. detailData: {},
  148. page: {
  149. pageSize: 20,
  150. currentPage: 1,
  151. total: 0,
  152. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  153. },
  154. key: 0,
  155. option: {},
  156. optionList: {
  157. viewBtn: false,
  158. editBtn: false,
  159. delBtn: false,
  160. addBtn: false,
  161. index: true,
  162. span: 8,
  163. border: true,
  164. height: "auto",
  165. searchMenuPosition: "right",
  166. align: "center",
  167. size: "small",
  168. menuWidth: 140,
  169. searchSpan: 8,
  170. searchIcon: true,
  171. searchIndex: 2,
  172. highlightCurrentRow: true,
  173. dialogWidth: "70%",
  174. column: [{
  175. label: '全称',
  176. prop: "cname",
  177. search: true,
  178. overHidden: true,
  179. },{
  180. label: '供应商分类',
  181. prop: "corpsTypeName",
  182. search: true,
  183. overHidden: true,
  184. }, {
  185. label: '电话',
  186. prop: "let",
  187. search: true,
  188. overHidden: true,
  189. }, {
  190. label: "业务员",
  191. prop: "salesmanId",
  192. search: true,
  193. type: "select",
  194. props: {
  195. label: "name",
  196. value: "id"
  197. },
  198. dicUrl: "/api/blade-user/client/gainUser",
  199. filterable: true,
  200. overHidden: true
  201. }, {
  202. label: '备注',
  203. prop: "remarks",
  204. search: true,
  205. overHidden: true,
  206. },{
  207. label: '是否启用',
  208. prop: 'enableOrNot'
  209. }]
  210. }
  211. }
  212. },
  213. async created() {
  214. this.option = await this.getColumnData(this.getColumnName(262), this.optionList);
  215. this.key++
  216. getCorpType({corpType: 'GYS'}).then(res => {
  217. this.treeData = res.data.data
  218. });
  219. let i = 0;
  220. this.option.column.forEach(item => {
  221. if (item.search) i++
  222. })
  223. if (i % 3 !== 0) {
  224. const num = 3 - Number(i % 3)
  225. this.option.searchMenuSpan = num * 8;
  226. this.option.searchMenuPosition = "right";
  227. }
  228. },
  229. methods: {
  230. addCorpType() {
  231. // this.$refs["corpType"].validate((valid, done) => {
  232. // done();
  233. // if (valid) {
  234. // addCorpType({ ...this.form4, corpType: 'KH', status: 0 })
  235. // .then(res => {
  236. // this.$message.success("保存成功");
  237. // this.getAllWorkDicts()
  238. // this.corpTypeVisible = false
  239. // })
  240. // } else {
  241. // return false;
  242. // }
  243. // });
  244. this.getAllWorkDicts()
  245. this.corpTypeVisible = false
  246. },
  247. corpTypeClosed() {
  248. // this.reload = Math.random();
  249. // this.form4 = this.$options.data().form4
  250. },
  251. nodeClick(data) {
  252. this.search.corpsTypeId = data.value
  253. this.page.currentPage = 1;
  254. this.onLoad(this.page, this.search);
  255. },
  256. derivation() {
  257. window.open(
  258. `/api/blade-client/corpsdesc/export-template?${this.website.tokenHeader
  259. }=${getToken()}`
  260. );
  261. },
  262. uploadBefore(file, done, loading) {
  263. done();
  264. loading = true;
  265. },
  266. uploadAfter(res, done, loading, column) {
  267. this.excelBox = false;
  268. this.$message.success("导入成功!");
  269. this.refreshChange();
  270. loading = false;
  271. done();
  272. },
  273. check(row) {
  274. this.form = row
  275. this.detailsOpen = true
  276. },
  277. backToList(type) {
  278. this.form = {}
  279. this.detailsOpen = false
  280. if (type === 0) {
  281. this.detailData = {}
  282. }
  283. this.onLoad(this.page, this.search)
  284. },
  285. //刷新
  286. refreshChange() {
  287. this.onLoad(this.page, this.search)
  288. },
  289. rowDel(form, index) {
  290. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  291. confirmButtonText: '确定',
  292. cancelButtonText: '取消',
  293. type: 'warning'
  294. }).then(() => {
  295. remove(form.id).then(res => {
  296. this.$message({
  297. type: 'success',
  298. message: '删除成功!'
  299. });
  300. this.dataList.splice(index, 1);
  301. this.onLoad(this.page)
  302. })
  303. }).catch(() => {
  304. });
  305. },
  306. searchChange(params, done) {
  307. done();
  308. this.onLoad(this.page, params)
  309. },
  310. onLoad(page, params = {}) {
  311. params = {
  312. ...params,
  313. current: page.currentPage,
  314. size: page.pageSize,
  315. corpType: "GYS",
  316. ...Object.assign(params, this.search)
  317. }
  318. this.loading = true
  319. getList(params).then(res => {
  320. this.dataList = res.data.data.records
  321. this.page.total = res.data.data.total
  322. this.loading = false
  323. }).finally(() => {
  324. this.loading = false
  325. })
  326. },
  327. //自定义列保存
  328. async saveColumnTwo(ref, option, optionBack, code) {
  329. /**
  330. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  331. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  332. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  333. */
  334. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  335. if (inSave) {
  336. this.$message.success("保存成功");
  337. //关闭窗口
  338. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  339. }
  340. },
  341. //自定义列重置
  342. async resetColumnTwo(ref, option, optionBack, code) {
  343. this[option] = this[optionBack];
  344. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  345. if (inSave) {
  346. this.$message.success("重置成功");
  347. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  348. }
  349. }
  350. }
  351. }
  352. </script>
  353. <style lang="scss" scoped>
  354. ::v-deep .el-input-group__append {
  355. padding: 0 0px !important;
  356. }
  357. </style>