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. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  10. <i class="el-icon-setting" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"
  11. @click="corpTypeVisible = true"></i>
  12. </el-tooltip>
  13. </template>
  14. </avue-tree>
  15. </el-col>
  16. <el-col :span="20">
  17. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  18. ref="crud" :key="key" @on-load="onLoad" @search-change="searchChange" @row-del="rowDel"
  19. @refresh-change="refreshChange" @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 262)"
  20. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 262)" :page.sync="page">
  21. <template slot-scope="{type,size,row,index}" slot="menu">
  22. <el-button :size="size" :type="type" @click="check(row)">查看</el-button>
  23. <el-button :size="size" :type="type"
  24. @click="$refs.crud.rowDel(row, index)">删除</el-button>
  25. </template>
  26. <!-- <template slot="enableOrNot" slot-scope="{row,index,disabled}">
  27. <el-switch active-value="1" inactive-value="0" :disabled="disabled" v-model="row.enableOrNot">
  28. </el-switch>
  29. </template> -->
  30. <template slot="corpNameSearch">
  31. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  32. </template>
  33. <template slot="shippingCompanyNameSearch">
  34. <crop-select v-model="search.shippingCompanyId" corpType="KH" :refresh="false"></crop-select>
  35. </template>
  36. <template slot-scope="scope" slot="bookingAgentSearch">
  37. <crop-select v-model="search.bookingAgentId" corpType="KH" :refresh="false"></crop-select>
  38. </template>
  39. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  40. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新增供应商</el-button>
  41. <el-button type="primary" size="small" icon="el-icon-bottom" @click="excelBox = true">导入</el-button>
  42. </template>
  43. </avue-crud>
  44. </el-col>
  45. </el-row>
  46. </basic-container>
  47. <el-dialog title="导入供应商" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  48. v-dialog-drag>
  49. <avue-form :option="excelOption" v-model="excelForm" table-loading="excelLoading" :upload-before="uploadBefore"
  50. :upload-after="uploadAfter">
  51. <template slot="excelTemplate">
  52. <el-button type="primary" @click="derivation">
  53. 点击下载<i class="el-icon-download el-icon--right"></i>
  54. </el-button>
  55. </template>
  56. </avue-form>
  57. <p style="text-align: center;color: #DC0505">
  58. 温馨提示 第一次导入时请先下载模板
  59. </p>
  60. </el-dialog>
  61. <el-dialog title="设置供应商分类" v-dialogDrag :visible.sync="corpTypeVisible" class="avue-dialog" width="80%" append-to-body
  62. @closed="corpTypeClosed">
  63. <span>
  64. <corp-type corpType="GYS"></corp-type>
  65. <!-- <avue-form :key="reload" ref="corpType" v-model="form4" :option="option4" style="margin-top:20px">
  66. </avue-form> -->
  67. </span>
  68. <div class="avue-dialog__footer">
  69. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  70. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  71. </div>
  72. </el-dialog>
  73. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  74. </div>
  75. </template>
  76. <script>
  77. // import {getList, remove} from "@/api/oceanShipping/maritimeExport/index.js";
  78. import detailsPage from "./detailsPage"
  79. import { getToken } from "@/util/auth";
  80. import { getCorpType, getList, remove } from "@/api/tirePartsMall/basicData/customerInformation";
  81. import corpType from "./components/index";
  82. import { option } from "../commodityInformation/js/optionList";
  83. export default {
  84. name: "index",
  85. components: {
  86. corpType,
  87. detailsPage
  88. },
  89. data() {
  90. return {
  91. treeData: [],
  92. corpTypeVisible: false,
  93. treeOption: {
  94. addBtn: false,
  95. menu: false,
  96. size: "small",
  97. props: {
  98. labelText: "标题",
  99. label: "title",
  100. value: "value",
  101. }
  102. },
  103. excelBox: false,
  104. excelForm: {},
  105. excelOption: {
  106. submitBtn: false,
  107. emptyBtn: false,
  108. column: [
  109. {
  110. label: "模板下载",
  111. prop: "excelTemplate",
  112. formslot: true,
  113. span: 24
  114. },
  115. {
  116. label: "模板上传",
  117. prop: "excelFile",
  118. type: "upload",
  119. drag: true,
  120. loadText: "模板上传中,请稍等",
  121. span: 24,
  122. propsHttp: {
  123. res: "data"
  124. },
  125. tip: "请上传 .xls,.xlsx 标准格式文件",
  126. action: "/api/blade-sales-part/corpsDesc/supplierImport?corpType=GYS"
  127. }
  128. ]
  129. },
  130. detailsOpen: false,
  131. loading: false,
  132. search: {},
  133. form: {},
  134. dataList: [],
  135. detailData: {},
  136. page: {
  137. pageSize: 20,
  138. currentPage: 1,
  139. total: 0,
  140. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  141. },
  142. key: 0,
  143. option: {},
  144. optionList: {
  145. viewBtn: false,
  146. editBtn: false,
  147. delBtn: false,
  148. addBtn: false,
  149. index: true,
  150. span: 8,
  151. border: true,
  152. align: "center",
  153. // height: "auto",
  154. Height: '50',
  155. searchMenuPosition: "right",
  156. size: "small",
  157. menuWidth: 100,
  158. searchSpan: 8,
  159. searchIcon: true,
  160. searchIndex: 2,
  161. highlightCurrentRow: true,
  162. dialogWidth: "70%",
  163. column: [{
  164. label: '全称',
  165. prop: "cname",
  166. search: {
  167. fuzzy: true // 启用模糊搜索
  168. },
  169. props: {
  170. label: "cname",
  171. value: "id"
  172. },
  173. overHidden: true,
  174. }, {
  175. label: '供应商分类',
  176. prop: "corpsTypeName",
  177. overHidden: true,
  178. }, {
  179. label: '电话',
  180. prop: "tel",
  181. search: true,
  182. overHidden: true,
  183. }, {
  184. label: "业务员",
  185. prop: "salesmanId",
  186. search: true,
  187. type: "select",
  188. props: {
  189. label: "name",
  190. value: "id"
  191. },
  192. dicUrl: "/api/blade-user/client/getUserByRole",
  193. filterable: true,
  194. overHidden: true
  195. }, {
  196. label: '备注',
  197. prop: "remarks",
  198. search: true,
  199. overHidden: true,
  200. }, {
  201. label: '是否启用',
  202. prop: 'enableOrNot',
  203. dicData: [{
  204. label: '是',
  205. value: 1
  206. }, {
  207. label: '否',
  208. value: 0
  209. }]
  210. }]
  211. }
  212. }
  213. },
  214. async created() {
  215. this.option = await this.getColumnData(this.getColumnName(262), this.optionList);
  216. this.key++
  217. getCorpType({ corpType: 'GYS' }).then(res => {
  218. console.log('看看');
  219. this.treeData = res.data.data
  220. });
  221. let i = 0;
  222. this.option.column.forEach(item => {
  223. if (item.search) i++
  224. })
  225. if (i % 3 !== 0) {
  226. const num = 3 - Number(i % 3)
  227. this.option.searchMenuSpan = num * 8;
  228. this.option.searchMenuPosition = "right";
  229. }
  230. },
  231. // activated() {
  232. // this.$nextTick(() => {
  233. // this.$refs.crud.doLayout()
  234. // })
  235. // },
  236. methods: {
  237. addCorpType() {
  238. // this.$refs["corpType"].validate((valid, done) => {
  239. // done();
  240. // if (valid) {
  241. // addCorpType({ ...this.form4, corpType: 'KH', status: 0 })
  242. // .then(res => {
  243. // this.$message.success("保存成功");
  244. // this.getAllWorkDicts()
  245. // this.corpTypeVisible = false
  246. // })
  247. // } else {
  248. // return false;
  249. // }
  250. // });
  251. // this.getAllWorkDicts()
  252. this.corpTypeVisible = false
  253. },
  254. corpTypeClosed() {
  255. this.refresh()
  256. console.log(234324);
  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>