index.vue 12 KB

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