index.vue 18 KB

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