index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div>
  3. <basic-container>
  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. </avue-tree>
  9. </el-col>
  10. <el-col :span="20">
  11. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  12. ref="crud" :key="key" @on-load="onLoad" @selection-change="selectionChange"
  13. :before-open="beforeOpen"
  14. @row-update="rowUpdate" @search-change="searchChange" @refresh-change="refreshChange"
  15. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 273.1)"
  16. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 273.1)" :page.sync="page">
  17. <template slot="filesListForm">
  18. <span style="font-size: 12px;">(图片文件像素推荐700X750,有且只允许有一张主图,其余均为副图)</span>
  19. <c-upload :data="form.filesList" display basic deleteUrl="/api/blade-sales-part/productLaunchFiles/remove"
  20. :enumerationValue="160"/>
  21. </template>
  22. <template slot="detailsTextForm">
  23. <avue-ueditor v-model="form.detailsText" :options="optionsUeditor"></avue-ueditor>
  24. </template>
  25. <template slot-scope="{type,size,row,index}" slot="menu">
  26. <el-button :size="size" :type="type" :disabled="row.upAndDownShelves" @click="$refs.crud.rowEdit(row, index)">编辑
  27. </el-button>
  28. <el-tooltip :content="`${row.upAndDownShelves == 0?'上架':'下架'}`" placement="top">
  29. <el-switch
  30. style="margin-left: 10px"
  31. v-model="row.upAndDownShelves"
  32. @change="check(row)"
  33. :active-value="1"
  34. :inactive-value="0">
  35. </el-switch>
  36. </el-tooltip>
  37. </template>
  38. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  39. <el-button class="el-icon-document-copy" :disabled="selectionList.length === 0" type="primary"
  40. size="small"
  41. @click="change(row, 'up')">批量上架
  42. </el-button>
  43. <el-button class="el-icon-document-copy" :disabled="selectionList.length === 0" type="danger" size="small"
  44. @click="change(row, 'down')">批量下架
  45. </el-button>
  46. <!--<el-button class="el-icon-bottom" type="warning" size="small" @click="excelBox = true">-->
  47. <!-- 导入-->
  48. <!--</el-button>-->
  49. </template>
  50. </avue-crud>
  51. </el-col>
  52. </el-row>
  53. </basic-container>
  54. <el-dialog title="添加产品" append-to-body :visible.sync="excelBox" :close-on-click-modal="false" width="555px">
  55. <avue-form :option="excelOption" v-model="excelForm" :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. </div>
  67. </template>
  68. <script>
  69. import {
  70. getList,
  71. submit,
  72. batchOperationProductLaunch,
  73. getDetail, listAll
  74. } from "@/api/tirePartsMall/basicData/listingManagement/index.js";
  75. import {getToken} from "@/util/auth";
  76. import fa from "element-ui/src/locale/lang/fa";
  77. export default {
  78. name: "index",
  79. data() {
  80. return {
  81. optionsUeditor: {
  82. //普通上传地址
  83. // action:'https://avuejs.com/imgupload',
  84. action: "/api/blade-resource/oss/endpoint/put-file",
  85. headers: {"Blade-Auth": "Bearer " + getToken()},
  86. props: {
  87. res: "data",
  88. url: 'link'
  89. }
  90. },
  91. excelForm: {},
  92. excelOption: {
  93. submitBtn: false,
  94. emptyBtn: false,
  95. column: [
  96. {
  97. label: "模板下载",
  98. prop: "excelTemplate",
  99. formslot: true,
  100. span: 24
  101. },
  102. {
  103. label: "模板上传",
  104. prop: "excelFile",
  105. type: "upload",
  106. drag: true,
  107. loadText: "模板上传中,请稍等",
  108. span: 24,
  109. propsHttp: {
  110. res: "data"
  111. },
  112. tip: "请上传 .xls,.xlsx 标准格式文件",
  113. action: "/api/blade-sales-part/productLaunch/import-productLaunch"
  114. }
  115. ]
  116. },
  117. treeOption: {
  118. addBtn: false,
  119. menu: false,
  120. size: "small",
  121. props: {
  122. labelText: "标题",
  123. label: "cname",
  124. value: "id",
  125. }
  126. },
  127. excelBox: false,
  128. corpTypeVisible: false,
  129. treeData: [],
  130. loading: false,
  131. search: {},
  132. form: {},
  133. dataList: [],
  134. selectionList: [],
  135. page: {
  136. pageSize: 20,
  137. currentPage: 1,
  138. total: 0,
  139. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  140. },
  141. key: 0,
  142. option: {},
  143. optionList: {
  144. viewBtn: false,
  145. editBtn: false,
  146. delBtn: false,
  147. addBtn: false,
  148. index: true,
  149. span: 8,
  150. border: true,
  151. updateBtnText:'保存',
  152. selection: true,
  153. height: "auto",
  154. searchMenuPosition: "right",
  155. align: "center",
  156. menuWidth: 100,
  157. updateBtnText:'保存',
  158. searchSpan: 8,
  159. searchIcon: true,
  160. searchIndex: 2,
  161. highlightCurrentRow: true,
  162. dialogWidth: "70%",
  163. column: [{
  164. label: '轮胎名称',
  165. prop: 'cname',
  166. search: true,
  167. disabled: true,
  168. overHidden: true,
  169. }, {
  170. label: '规格型号',
  171. prop: 'specificationAndModel',
  172. search: true,
  173. disabled: true,
  174. overHidden: true,
  175. },{
  176. label: '花纹',
  177. prop: 'brandItem',
  178. disabled: true,
  179. overHidden: true,
  180. }, {
  181. label: '公司',
  182. prop: 'salesCompanyId',
  183. disabled: true,
  184. overHidden: true,
  185. type: 'select',
  186. props: {
  187. label: 'fullName',
  188. value: 'id'
  189. },
  190. dicUrl: '/api/blade-system/dept/top-list'
  191. }, {
  192. label: '库存',
  193. prop: 'inventory',
  194. disabled: true,
  195. overHidden: true,
  196. }, {
  197. label: '产品状态',
  198. prop: 'upAndDownShelves',
  199. filterable: true,
  200. display: false,
  201. search: true,
  202. hide: true,
  203. disabled: true,
  204. showColumn: false,
  205. type: 'select',
  206. dicData: [{
  207. label: "上架",
  208. value: 1
  209. }, {
  210. label: "下架",
  211. value: 0
  212. }]
  213. }, {
  214. label: "品牌",
  215. prop: "brandName",
  216. disabled: true,
  217. overHidden: true,
  218. }, {
  219. label: "售价1",
  220. prop: "priceOne",
  221. hide: true,
  222. showColumn: false,
  223. overHidden: true,
  224. }, {
  225. label: "售价2",
  226. prop: "priceTwo",
  227. hide: true,
  228. showColumn: false,
  229. overHidden: true,
  230. }, {
  231. label: "售价3",
  232. prop: "priceThree",
  233. hide: true,
  234. showColumn: false,
  235. overHidden: true,
  236. }, {
  237. label: "售价4",
  238. prop: "priceFour",
  239. hide: true,
  240. showColumn: false,
  241. overHidden: true,
  242. }, {
  243. label: "共享成本",
  244. prop: "shareCost",
  245. overHidden: true,
  246. }, {
  247. label: "来源公司",
  248. prop: "sourceCompanyId",
  249. hide: true,
  250. search: true,
  251. showColumn: true,
  252. overHidden: true,
  253. disabled: true,
  254. type: 'select',
  255. props: {
  256. label: 'fullName',
  257. value: 'id'
  258. },
  259. dicUrl: '/api/blade-system/dept/top-list'
  260. }, {
  261. label: "详情附件",
  262. prop: "filesList",
  263. hide: true,
  264. showColumn: false,
  265. overHidden: true,
  266. span: 24,
  267. }, {
  268. label: "轮胎详情",
  269. prop: "detailsText",
  270. hide: true,
  271. span: 24,
  272. showColumn: false,
  273. overHidden: true,
  274. }]
  275. }
  276. }
  277. },
  278. activated() {
  279. listAll().then(res=>{
  280. this.treeData = res.data.data
  281. })
  282. this.onLoad(this.page, this.search)
  283. },
  284. async created() {
  285. this.option = await this.getColumnData(this.getColumnName(273.1), this.optionList);
  286. this.key++
  287. let i = 0;
  288. this.option.column.forEach(item => {
  289. if (item.search) i++
  290. })
  291. if (i % 3 !== 0) {
  292. const num = 3 - Number(i % 3)
  293. this.option.searchMenuSpan = num * 8;
  294. this.option.searchMenuPosition = "right";
  295. }
  296. },
  297. methods: {
  298. derivation() {
  299. window.open(
  300. `/api/blade-sales-part/productLaunch/export-productLaunch?${this.website.tokenHeader
  301. }=${getToken()}`
  302. );
  303. },
  304. uploadAfter(res, done, loading, column) {
  305. this.excelBox = false;
  306. this.refreshChange();
  307. done();
  308. },
  309. nodeClick(data) {
  310. this.search.brandId = data.id
  311. this.page.currentPage = 1;
  312. this.onLoad(this.page, this.search);
  313. },
  314. //刷新
  315. refreshChange() {
  316. this.onLoad(this.page, this.search)
  317. },
  318. searchChange(params, done) {
  319. done();
  320. this.onLoad(this.page, params)
  321. },
  322. selectionChange(list) {
  323. this.selectionList = list
  324. },
  325. //打开表单前
  326. beforeOpen(done, type) {
  327. // 查看和编辑逻辑
  328. if (['view', 'edit'].includes(type)) {
  329. getDetail({id: this.form.id}).then(res => {
  330. this.form = res.data.data
  331. done();
  332. })
  333. }
  334. },
  335. //编辑确定
  336. rowUpdate(form, index, done, loading) {
  337. if (this.form.filesList.length > 0) {
  338. let flag = this.form.filesList.some(item => {
  339. return item.$version == '主图'
  340. })
  341. if (!flag) {
  342. this.$message.warning('请选择主图')
  343. done()
  344. return
  345. }
  346. }
  347. submit({
  348. ...this.form
  349. }).then(res => {
  350. this.$message.success("修改成功")
  351. this.onLoad(this.page, this.search)
  352. done()
  353. }).catch((err) => {
  354. loading()
  355. })
  356. // submit({
  357. // ...form
  358. // }).then(res => {
  359. // this.onLoad(this.page, this.search)
  360. // done()
  361. // }).catch(() => {
  362. // loading()
  363. // })
  364. },
  365. check(row) {
  366. batchOperationProductLaunch({
  367. flag: row.upAndDownShelves,
  368. ids: row.id
  369. }).then(res => {
  370. this.onLoad(this.page, this.search)
  371. })
  372. },
  373. change(row, type) {
  374. let data = []
  375. for (let item of this.selectionList) {
  376. data.push(item.id)
  377. }
  378. if (type === "up") {
  379. // for (let item of this.selectionList) {
  380. // if (!Number(item.salesPrice)) return this.$message.error("上架失败,商城价格不能为0")
  381. // }
  382. this.$confirm('是否确认全部上架?', '提示', {
  383. confirmButtonText: '确定',
  384. cancelButtonText: '取消',
  385. type: 'warning'
  386. }).then(() => {
  387. batchOperationProductLaunch({
  388. flag: 1,
  389. ids: data.join(",")
  390. }).then(res => {
  391. this.onLoad(this.page, this.search)
  392. })
  393. })
  394. } else if (type === "down") {
  395. this.$confirm('是否确认全部下架?', '提示', {
  396. confirmButtonText: '确定',
  397. cancelButtonText: '取消',
  398. type: 'warning'
  399. }).then(() => {
  400. batchOperationProductLaunch({
  401. flag: 0,
  402. ids: data.join(",")
  403. }).then(res => {
  404. this.onLoad(this.page, this.search)
  405. })
  406. })
  407. }
  408. },
  409. onLoad(page, params = {}) {
  410. params = {
  411. ...params,
  412. current: page.currentPage,
  413. size: page.pageSize,
  414. ...Object.assign(params, this.search),
  415. billType: 1
  416. }
  417. this.loading = true
  418. getList(params).then(res => {
  419. this.dataList = res.data.data.records
  420. this.page.total = res.data.data.total
  421. this.$nextTick(() => {
  422. this.$refs.crud.doLayout();
  423. });
  424. this.loading = false
  425. }).finally(() => {
  426. this.loading = false
  427. })
  428. },
  429. //自定义列保存
  430. async saveColumnTwo(ref, option, optionBack, code) {
  431. /**
  432. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  433. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  434. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  435. */
  436. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  437. if (inSave) {
  438. this.$message.success("保存成功");
  439. //关闭窗口
  440. this.$nextTick(() => {
  441. this.$refs.crud.doLayout();
  442. });
  443. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  444. }
  445. },
  446. //自定义列重置
  447. async resetColumnTwo(ref, option, optionBack, code) {
  448. this[option] = this[optionBack];
  449. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  450. if (inSave) {
  451. this.$message.success("重置成功");
  452. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  453. this.$nextTick(() => {
  454. this.$refs.crud.doLayout();
  455. });
  456. }
  457. }
  458. }
  459. }
  460. </script>
  461. <style scoped></style>