index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div>
  3. <el-card style="height: calc(100vh - 110px)" class="scroll">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true">
  5. <el-form-item label="群组品号" prop="code">
  6. <el-input v-model="queryParams.code" placeholder="请输入群组品号" clearable size="small" @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="群组品名" prop="nameChinese">
  9. <el-input v-model="queryParams.nameChinese" placeholder="请输入群组品名" clearable size="small" @keyup.enter.native="handleQuery" />
  10. </el-form-item>
  11. <!-- <el-form-item label="品牌" prop="brandName">
  12. <el-select v-model="queryParams.brandName" placeholder="请选择品牌" size="small" @change="handleQuery">
  13. <el-option v-for="item in brandName" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  14. </el-select>
  15. </el-form-item> -->
  16. <el-form-item label="品号" prop="specCode">
  17. <el-input v-model="queryParams.specCode" placeholder="请输入品号" clearable size="small" @keyup.enter.native="handleQuery" />
  18. </el-form-item>
  19. <el-form-item label="品名" prop="colorNameChinese">
  20. <el-input v-model="queryParams.colorNameChinese" placeholder="请输入品名" clearable size="small" @keyup.enter.native="handleQuery" />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button size="small" @click="handleQuery" class="searchBtn">搜索</el-button>
  24. <el-button size="small" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" style="margin-bottom: 10px" v-if="!userInfo.subsidiaryId">
  28. <el-col :span="24">
  29. <el-button type="primary" size="mini" @click="handleAdd">添加产品</el-button>
  30. <!-- <el-button type="primary" size="mini" @click="importExcel" v-db-click>导入Excel</el-button>
  31. <el-button type="primary" size="mini" @click="historyManagement" v-db-click>导入历史管理</el-button> -->
  32. </el-col>
  33. </el-row>
  34. <el-table
  35. v-loading="loadingTable"
  36. :data="productList"
  37. size="small"
  38. :row-style="{ height: '35px' }"
  39. :cell-style="{ padding: '0' }"
  40. header-row-class-name="tableHeader"
  41. >
  42. <el-table-column label="" type="expand" width="50">
  43. <template slot-scope="scope">
  44. <div style="padding: 0px 20px; box-sizing: border-box">
  45. <div
  46. v-for="(color, index) in scope.row.colors"
  47. :key="index"
  48. style="display: flex; padding: 3px 10px; align-items: center; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); margin-bottom: 8px"
  49. >
  50. <div style="width: 80px">
  51. <div v-if="color.colorAccessory">
  52. <img
  53. v-if="!color.colorAccessory.includes('https')"
  54. style="width: 40px; height: 40px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer"
  55. :src="pathPrefix + color.colorAccessory"
  56. @click="openFile(pathPrefix + color.colorAccessory)"
  57. />
  58. <img
  59. v-else
  60. style="width: 40px; height: 40px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer"
  61. :src="color.colorAccessory"
  62. @click="openFile(color.colorAccessory)"
  63. />
  64. </div>
  65. <div
  66. v-else
  67. class="el-icon-picture-outline"
  68. style="width: 40px; height: 40px; font-size: 36px; line-height: 40px; text-align: center; color: rgb(229 228 228)"
  69. ></div>
  70. </div>
  71. <div style="width: 140px">
  72. {{ color.specCode }}
  73. </div>
  74. <div style="flex: 1">
  75. {{ color.nameChinese }}
  76. </div>
  77. <div style="width: 160px">
  78. {{ `${color.length} * ${color.width} * ${color.height}(cm³)` }}
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="群组品号" prop="code" width="120" />
  85. <el-table-column label="群组品名" min-width="220">
  86. <template slot-scope="scope">
  87. <div>
  88. <a style="color: #409eff; cursor: pointer" @click="clickProductName(scope.row)">{{ scope.row.nameChinese }}</a>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="品牌" prop="brandName" width="100" />
  93. <el-table-column label="型号" prop="productModelChinese" min-width="150" />
  94. <el-table-column label="材质" prop="materialChinese" min-width="150" />
  95. <el-table-column label="操作" align="center" width="100" fixed="right" v-if="!userInfo.subsidiaryId">
  96. <template slot-scope="scope">
  97. <el-button type="text" @click="handleUpdate(scope.row)" v-db-click>编辑</el-button>
  98. <el-button type="text" @click="handleDelete(scope.row)" v-db-click>删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  103. </el-card>
  104. <!-- 添加或修改产品信息对话框 -->
  105. <el-dialog v-if="openProduct" :visible.sync="openProduct" width="98%" append-to-body>
  106. <Product :rowData="rowData" @clickCancel="clickCancel"></Product>
  107. </el-dialog>
  108. <!-- 产品详情 -->
  109. <el-dialog v-if="openDetails" :visible.sync="openDetails" width="98%" append-to-body>
  110. <ProductDetails :rowData="rowData" @clickCancel="clickCancelDetails"></ProductDetails>
  111. </el-dialog>
  112. <!-- 导入SKU -->
  113. <el-dialog title="导入SKU" v-if="openImportExcel" :visible.sync="openImportExcel" style="margin-top: 15vh" width="30%" append-to-body>
  114. <div
  115. v-loading="loadingStatus"
  116. element-loading-text="导入中,请稍后"
  117. element-loading-spinner="el-icon-loading"
  118. element-loading-background="rgba(0, 0, 0, 0.2)"
  119. >
  120. <el-row :gutter="10" style="margin-bottom: 15px">
  121. <el-col :span="1.5">
  122. <el-upload
  123. class="upload-demo"
  124. :action="actionProduct"
  125. :headers="{ 'Blade-Auth': 'bearer ' + token }"
  126. :show-file-list="false"
  127. :before-upload="beforeUpload"
  128. :on-progress="excelProgress"
  129. :on-success="excelSuccess"
  130. :on-error="excelError"
  131. accept=".xlsx"
  132. >
  133. <el-button type="primary" size="mini">导入文件</el-button>
  134. </el-upload>
  135. </el-col>
  136. </el-row>
  137. <el-row>
  138. <el-col :span="24">
  139. <el-tooltip placement="bottom" effect="light">
  140. <div slot="content">
  141. <div v-html="getStyle(errMsg)" style="max-height: 500px; overflow: auto; line-height: normal"></div>
  142. </div>
  143. <div style="cursor: pointer; color: #940819; overflow: hidden; white-space: nowrap; text-overflow: ellipsis">{{ errMsg }}</div>
  144. </el-tooltip>
  145. </el-col>
  146. </el-row>
  147. <div style="width: 100%; text-align: center; padding-top: 16px">
  148. <el-button @click="openImportExcel = false">取 消</el-button>
  149. </div>
  150. </div>
  151. </el-dialog>
  152. <!-- SKU导入历史 -->
  153. <el-dialog title="SKU导入历史" v-if="openHistory" :visible.sync="openHistory" width="40%" style="margin-top: 15vh" append-to-body>
  154. <div
  155. v-loading="loadingVersion"
  156. element-loading-text="还原版本中,请稍后"
  157. element-loading-spinner="el-icon-loading"
  158. element-loading-background="rgba(0, 0, 0, 0.2)"
  159. >
  160. <el-table
  161. :data="historyList"
  162. :cell-style="{ padding: '0' }"
  163. :row-style="{ height: '35px' }"
  164. header-row-class-name="tableHeader"
  165. v-loading="loadingHistory"
  166. border
  167. >
  168. <el-table-column label="版本时间" align="center" prop="createTime" />
  169. <el-table-column label="导入人" align="center" prop="userName" />
  170. <el-table-column label="操作" align="center" width="100" fixed="right">
  171. <template slot-scope="scope">
  172. <el-button type="text" @click="restoreVersion(scope.row)" v-db-click>还原版本</el-button>
  173. </template>
  174. </el-table-column>
  175. </el-table>
  176. <pagination
  177. v-show="historyTotal > 0"
  178. :total="historyTotal"
  179. :page.sync="queryParamsTwo.pageNum"
  180. :limit.sync="queryParamsTwo.pageSize"
  181. @pagination="getHistoryList"
  182. />
  183. <div style="width: 100%; text-align: center; padding-top: 16px">
  184. <el-button type="primary" @click="openHistory = false">确 定</el-button>
  185. </div>
  186. </div>
  187. </el-dialog>
  188. </div>
  189. </template>
  190. <script>
  191. import * as API from '@/api/shengde/product/groupSKU'
  192. import { del } from '@/api/product/customProductLibrary'
  193. import { mapGetters } from 'vuex'
  194. import Product from './product'
  195. import ProductDetails from './details'
  196. import { versionList, versionListCount, backupVersion } from '@/api/shengde/group/order/orderManagement.js'
  197. export default {
  198. name: 'groupSKU',
  199. components: { Product, ProductDetails },
  200. data() {
  201. return {
  202. pathPrefix: process.env.VUE_APP_IMG_URL,
  203. inputCategory: '',
  204. categoryTreeData: [],
  205. defaultProps: {
  206. children: 'children',
  207. label: 'text',
  208. },
  209. // 总条数
  210. total: 0,
  211. // 产品信息表格数据
  212. productList: [],
  213. loadingTable: false,
  214. // 是否显示弹出层
  215. openProduct: false,
  216. // 查询参数
  217. queryParams: {
  218. pageNum: 1,
  219. pageSize: 10,
  220. categoryId: '',
  221. code: '',
  222. brandName: '',
  223. nameChinese: '',
  224. specCode: '',
  225. colorNameChinese: '',
  226. type: '',
  227. subsidiaryId: '',
  228. purchaseContractId: '',
  229. },
  230. fileData: [],
  231. rowData: {},
  232. openDetails: false,
  233. openImportExcel: false,
  234. actionProduct: process.env.VUE_APP_ACTION_PRODUCT_URL,
  235. loadingStatus: false,
  236. openHistory: false,
  237. loadingHistory: false,
  238. queryParamsTwo: {
  239. pageNum: 1,
  240. pageSize: 10,
  241. model: '1',
  242. },
  243. historyList: [],
  244. historyTotal: 0,
  245. loadingVersion: false,
  246. }
  247. },
  248. created() {},
  249. mounted() {
  250. this.getList()
  251. },
  252. computed: mapGetters(['dictData', 'userInfo', 'token']),
  253. methods: {
  254. handleNodeClick(data) {
  255. this.queryParams.pageNum = 1
  256. if (data.dictKey) {
  257. this.queryParams.categoryType = data.dictKey
  258. this.queryParams.categoryId = ''
  259. } else {
  260. this.queryParams.categoryType = ''
  261. this.queryParams.categoryId = data.id
  262. }
  263. this.getList()
  264. },
  265. /** 查询产品信息列表 */
  266. getList() {
  267. this.loadingTable = true
  268. API.getGroupList(this.queryParams).then(
  269. (response) => {
  270. this.total = response.data.data.total
  271. response.data.data.records = response.data.data.records.map((item) => {
  272. if (!item.subsidiaryPrice) {
  273. item.subsidiaryPrice = undefined
  274. }
  275. if (item.colors && item.colors.length > 0) {
  276. item.colors = item.colors.map((itemColors) => {
  277. itemColors.nameChinese = itemColors.nameChinese.replace(item.nameChinese + ' : ', '')
  278. itemColors.nameChinese = itemColors.nameChinese.replace(item.nameChinese + ':', '')
  279. return {
  280. ...itemColors,
  281. }
  282. })
  283. }
  284. return {
  285. ...item,
  286. }
  287. })
  288. this.productList = response.data.data.records
  289. this.loadingTable = false
  290. },
  291. (err) => {
  292. console.log('getGroupList: ' + err)
  293. this.loadingTable = false
  294. }
  295. )
  296. },
  297. /** 搜索按钮操作 */
  298. handleQuery() {
  299. this.queryParams.pageNum = 1
  300. this.getList()
  301. },
  302. /** 重置按钮操作 */
  303. resetQuery() {
  304. this.resetForm('queryForm')
  305. this.handleQuery()
  306. },
  307. /** 新增按钮操作 */
  308. handleAdd() {
  309. this.rowData = {
  310. dataResource: 0,
  311. }
  312. this.openProduct = true
  313. },
  314. /** 修改按钮操作 */
  315. handleUpdate(row) {
  316. this.rowData = row
  317. this.openProduct = true
  318. },
  319. /** 删除按钮操作 */
  320. handleDelete(row) {
  321. this.$confirm('是否确认删除群组品名为"' + row.nameChinese + '"的数据项?', '警告', {
  322. confirmButtonText: '确定',
  323. cancelButtonText: '取消',
  324. type: 'warning',
  325. })
  326. .then(() => {
  327. del({ id: row.id }).then(() => {
  328. this.msgSuccess('删除成功')
  329. this.getList()
  330. })
  331. })
  332. .catch(() => {})
  333. },
  334. clickProductName(row) {
  335. this.rowData = row
  336. this.openDetails = true
  337. },
  338. clickCancel(status) {
  339. this.openProduct = false
  340. if (status) {
  341. this.getList()
  342. }
  343. },
  344. clickCancelDetails() {
  345. this.openDetails = false
  346. },
  347. openFile(path) {
  348. window.open(path)
  349. },
  350. importExcel() {
  351. this.errMsg = ''
  352. this.openImportExcel = true
  353. },
  354. getStyle(text) {
  355. if (text) {
  356. return text.replace(/\n|\r\n/g, '<br>')
  357. } else {
  358. return ''
  359. }
  360. },
  361. beforeUpload(file) {
  362. this.errMsg = ''
  363. const isLt50M = file.size / 1024 / 1024 < 50
  364. if (!isLt50M) {
  365. this.$message.error('上传文件大小不能超过50MB!')
  366. }
  367. return isLt50M
  368. },
  369. excelProgress() {
  370. this.loadingStatus = true
  371. },
  372. excelSuccess(msg) {
  373. if (msg && msg.data) {
  374. this.msgSuccess('文件导入成功: ' + msg.data)
  375. } else {
  376. this.msgSuccess('文件导入成功')
  377. }
  378. this.loadingStatus = false
  379. this.openImportExcel = false
  380. this.getList()
  381. },
  382. excelError(err) {
  383. var res = JSON.parse(err.message)
  384. this.errMsg = '导入失败: ' + res.msg
  385. this.loadingStatus = false
  386. },
  387. historyManagement() {
  388. this.historyTotal = 0
  389. this.historyList = []
  390. this.queryParamsTwo = {
  391. pageNum: 1,
  392. pageSize: 10,
  393. model: '1',
  394. }
  395. this.loadingVersion = false
  396. this.openHistory = true
  397. this.getHistoryList()
  398. },
  399. getHistoryList() {
  400. this.loadingHistory = true
  401. versionList(this.queryParamsTwo).then(
  402. (res) => {
  403. this.historyList = res.data.data.list
  404. this.loadingHistory = false
  405. },
  406. (err) => {
  407. console.log('versionList:' + err)
  408. this.loadingHistory = false
  409. }
  410. )
  411. versionListCount(this.queryParamsTwo).then((res) => {
  412. this.historyTotal = res.data.data.count
  413. })
  414. },
  415. restoreVersion(row) {
  416. this.loadingVersion = true
  417. backupVersion({ id: row.id }).then(
  418. (res) => {
  419. this.msgSuccess('版本还原成功')
  420. this.loadingVersion = false
  421. this.openHistory = false
  422. this.getList()
  423. },
  424. (err) => {
  425. console.log('backupVersion: ' + err)
  426. this.loadingVersion = false
  427. }
  428. )
  429. },
  430. },
  431. }
  432. </script>
  433. <style lang="scss" scoped>
  434. /deep/ .el-tree-node__label {
  435. font-size: 12px !important;
  436. }
  437. * {
  438. font-size: 12px;
  439. }
  440. .el-tree {
  441. display: inline-block;
  442. min-width: 100%;
  443. }
  444. ::v-deep {
  445. .el-input__inner {
  446. border-radius: 1px;
  447. }
  448. .el-button--mini {
  449. border-radius: 1px;
  450. }
  451. .tableHeader th {
  452. background-color: #edf0f5;
  453. height: 35px;
  454. padding: 0;
  455. }
  456. .el-dialog__footer {
  457. text-align: center;
  458. padding-bottom: 50px;
  459. .el-button {
  460. border-radius: 1px;
  461. }
  462. }
  463. .el-card__body {
  464. padding: 15px;
  465. }
  466. .el-table__cell {
  467. vertical-align: middle !important;
  468. }
  469. .el-input-number {
  470. .el-input__inner {
  471. text-align: left !important;
  472. }
  473. }
  474. }
  475. .box-card {
  476. height: calc(100vh - 50px - 50px - 10px);
  477. // overflow-y: auto;
  478. }
  479. .searchBtn {
  480. background: #20b2aa;
  481. color: #fff;
  482. border: 1px solid #20b2aa;
  483. }
  484. // 详情页需要加这个
  485. /deep/ .el-dialog {
  486. margin: 0 auto;
  487. margin-top: 10px !important;
  488. }
  489. .scroll {
  490. overflow: hidden overlay !important;
  491. &::-webkit-scrollbar {
  492. width: 0px;
  493. }
  494. &:hover {
  495. &::-webkit-scrollbar {
  496. width: 7px;
  497. }
  498. }
  499. }
  500. </style>