index.vue 12 KB

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