batchModification.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <div style="height: calc(100vh - 58px - 20px - 114px); overflow-y: auto; overflow-x: hidden">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
  4. <el-form-item label="群组品号" prop="specCode">
  5. <el-input v-model="queryParams.specCode" placeholder="请输入群组品号" size="small" @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="BOM品号" prop="bomColorCode">
  8. <el-input v-model="queryParams.bomColorCode" placeholder="请输入BOM品号" size="small" @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="尺寸 (cm):">
  11. <el-row :gutter="10">
  12. <el-col :span="8">
  13. <el-form-item label="" prop="length">
  14. <el-input-number size="small" v-model="queryParams.length" placeholder="请输入长" :precision="2" :controls="false" :min="0" />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="8">
  18. <el-form-item label="" prop="width">
  19. <el-input-number size="small" v-model="queryParams.width" placeholder="请输入宽" :precision="2" :controls="false" :min="0" />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="" prop="height">
  24. <el-input-number size="small" v-model="queryParams.height" placeholder="请输入高" :precision="2" :controls="false" :min="0" />
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button size="small" @click="handleQuery" class="searchBtn">搜索</el-button>
  31. <el-button size="small" @click="resetQuery">重置</el-button>
  32. </el-form-item>
  33. </el-form>
  34. <el-row :gutter="10">
  35. <el-col :span="24" style="display: flex">
  36. <div style="height: 40px; line-height: 40px; margin-right: 10px" v-if="!userInfo.subsidiaryId">
  37. <el-button type="primary" size="mini" @click="handleBOM()" v-db-click>选择bom</el-button>
  38. </div>
  39. <div style="height: 40px; line-height: 40px; margin-right: 10px" v-if="userInfo.subsidiaryId">
  40. <el-button type="primary" size="mini" @click="handleOpenOftenDialog()">选择常用包材</el-button>
  41. </div>
  42. <div style="height: 40px; line-height: 40px; margin-right: 10px" v-if="userInfo.subsidiaryId">
  43. <el-button type="primary" size="mini" style="background: #20b2aa; border-color: #20b2aa" @click="openSaveOftenDialog()">保存常用包材</el-button>
  44. </div>
  45. <div style="height: 40px; line-height: 40px; margin-right: 10px" v-if="userInfo.subsidiaryId">
  46. <el-button type="primary" size="mini" @click="handleOpenTwoBOM()">选择包材配件</el-button>
  47. </div>
  48. <div style="height: 40px; line-height: 40px; margin-right: 10px">
  49. <el-button type="text" @click="clickReset">重置</el-button>
  50. </div>
  51. <div style="height: 40px; line-height: 40px; margin-right: 10px">
  52. <el-button type="text" @click="clickReplace">一键替换</el-button>
  53. </div>
  54. <div style="margin-left: 32px">
  55. <el-form :model="specCode" :inline="true" @submit.native.prevent>
  56. <el-form-item label="BOM品号" prop="specCode">
  57. <el-input v-model="specCode" placeholder="请输入BOM品号" size="small" />
  58. </el-form-item>
  59. </el-form>
  60. </div>
  61. <div style="height: 40px; line-height: 40px; margin-right: 10px">
  62. <el-button type="text" @click="clickRemove">一键移除</el-button>
  63. </div>
  64. </el-col>
  65. </el-row>
  66. <el-form ref="ruleForm" :model="form" :rules="rules" label-width="100px">
  67. <el-table
  68. :data="form.selectData"
  69. :cell-style="{ padding: '0' }"
  70. :row-style="{ height: '35px' }"
  71. header-row-class-name="tableHeader"
  72. style="margin-bottom: 10px"
  73. >
  74. <el-table-column label="品号" prop="specCode" width="220" />
  75. <el-table-column label="品名" prop="bomColorName" min-width="220" />
  76. <el-table-column label="数量" align="center" width="200">
  77. <template slot-scope="scope">
  78. <el-form-item label-width="0px" :prop="'selectData.' + scope.$index + '.quantity'" :rules="rules.quantity" class="input">
  79. <el-input-number style="width: 100%" size="mini" v-model="scope.row.quantity" :controls="false" :min="1" :max="10000000" :precision="0" />
  80. </el-form-item>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" width="120">
  84. <template slot-scope="scope">
  85. <el-button type="text" @click="handleDelete(scope.$index)">删 除</el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </el-form>
  90. <br />
  91. <el-table
  92. :data="tableList"
  93. :cell-style="{ padding: '0' }"
  94. :row-style="{ height: '35px' }"
  95. v-loading="loading"
  96. header-row-class-name="tableHeader"
  97. ref="table"
  98. v-if="userInfo.subsidiaryId"
  99. >
  100. <el-table-column label="群组品号" prop="productCode" width="120" fixed />
  101. <el-table-column label="SKU品号" prop="specCode" width="140" fixed />
  102. <el-table-column label="品名" prop="nameChinese" min-width="220" fixed />
  103. <el-table-column label="裸垫品号" prop="bomColorCode" width="140" />
  104. <template v-if="packingFittings && packingFittings.length > 0">
  105. <el-table-column v-for="item in packingFittings" :key="item.id" :label="item.text + '品号'" width="140">
  106. <template slot-scope="scope">
  107. <span>{{ getLabel(scope.row, item) }}</span>
  108. </template>
  109. </el-table-column>
  110. </template>
  111. </el-table>
  112. <el-table
  113. :data="tableList"
  114. :cell-style="{ padding: '0' }"
  115. :row-style="{ height: '35px' }"
  116. v-loading="loading"
  117. header-row-class-name="tableHeader"
  118. ref="table"
  119. v-else
  120. >
  121. <el-table-column label="群组品号" prop="productCode" width="120" />
  122. <el-table-column label="SKU品号" prop="specCode" width="140" />
  123. <el-table-column label="品名" prop="nameChinese" min-width="220" />
  124. <el-table-column label="裸垫品号" prop="bomColorCode" width="140" />
  125. </el-table>
  126. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  127. <el-dialog v-if="openOftenDialog" :visible.sync="openOftenDialog" title="选择常用包材" width="60%" append-to-body>
  128. <el-form :model="composeQuery" ref="composeForm" :inline="true">
  129. <el-form-item label="组合名称" prop="name">
  130. <el-input placeholder="请输入" v-model="composeQuery.name" clearable size="small" @keyup.enter.native="handleGetList" />
  131. </el-form-item>
  132. <el-form-item>
  133. <el-button size="mini" @click="handleGetList" class="searchBtn">搜索</el-button>
  134. <el-button size="mini" @click="resetGetList">重置</el-button>
  135. </el-form-item>
  136. </el-form>
  137. <div class="compose-table">
  138. <el-table :data="oftenTableList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }" header-row-class-name="tableHeader">
  139. <el-table-column type="expand" align="left" width="50">
  140. <template slot-scope="scope">
  141. <div>
  142. <el-table :data="scope.row.bomCombinationDetailsList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }">
  143. <el-table-column label="主图" width="80" align="center">
  144. <template slot-scope="scope">
  145. <div v-if="scope.row.magPath">
  146. <img class="img" :src="pathPrefix + scope.row.magPath" @click="openFile(pathPrefix + scope.row.magPath)" />
  147. </div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="品号" prop="bomColorspecCode" />
  151. <el-table-column label="品名" prop="bomColorName" />
  152. <el-table-column label="数量" prop="singleQuantity" width="80" />
  153. <el-table-column label="单价¥" prop="price" width="80" align="right" />
  154. </el-table>
  155. </div>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="组合名称" prop="name" align="left" />
  159. <el-table-column label="操作" align="center" width="120" fixed="right">
  160. <template slot-scope="scope">
  161. <el-button type="text" @click="removeCompose(scope.row.id)">删 除</el-button>
  162. <el-button type="text" @click="selectCompose(scope.row)">选择</el-button>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. </div>
  167. <el-row style="text-align: center; margin-top: 30px">
  168. <el-button size="small" @click="openOftenDialog = false">取 消</el-button>
  169. </el-row>
  170. </el-dialog>
  171. <el-dialog v-if="saveOftenDialog" :visible.sync="saveOftenDialog" title="保存常用包材" width="40%" append-to-body>
  172. <el-form label-width="120px" :model="saveForm" ref="saveForm" :rules="rules">
  173. <el-form-item label="常用包材名称:" prop="name">
  174. <el-input v-model="saveForm.name" placeholder="请输入"> </el-input>
  175. </el-form-item>
  176. </el-form>
  177. <el-row style="text-align: center; margin-top: 30px">
  178. <el-button size="small" @click="saveCancel">取 消</el-button>
  179. <el-button size="small" type="primary" @click="saveOften">保 存</el-button>
  180. </el-row>
  181. </el-dialog>
  182. <!-- 选择包材配件-->
  183. <el-dialog title="选择包材配件" v-if="openTwoBOM" top="50px" :visible.sync="openTwoBOM" width="90%" append-to-body center>
  184. <SelectBOM @selectBOM="handleSelectTwoBOM" showType="parts"></SelectBOM>
  185. <span slot="footer" class="dialog-footer">
  186. <el-button @click="openTwoBOM = false">关 闭</el-button>
  187. </span>
  188. </el-dialog>
  189. <!-- 选择主材-->
  190. <el-dialog title="选择主材" v-if="openBOM" top="50px" :visible.sync="openBOM" width="80%" append-to-body center>
  191. <SelectBOM @selectBOM="handleSelectBOM" showType="principalMaterial"></SelectBOM>
  192. <span slot="footer" class="dialog-footer">
  193. <el-button @click="openBOM = false">关 闭</el-button>
  194. </span>
  195. </el-dialog>
  196. </div>
  197. </template>
  198. <script>
  199. import * as API from '@/api/shengde/product/batchModification'
  200. import { list, del, save } from '@/api/shengde/subsidiary/compose/index.js'
  201. import { categoryList } from '@/api/shengde/group/BOM/category'
  202. import SelectBOM from '@/components/shengde/SelectBOM/index'
  203. import { mapGetters } from 'vuex'
  204. export default {
  205. name: 'batchModification',
  206. components: { SelectBOM },
  207. data() {
  208. return {
  209. queryParams: {
  210. pageNum: 1,
  211. pageSize: 10,
  212. specCode: '',
  213. bomColorCode: '',
  214. length: undefined,
  215. width: undefined,
  216. height: undefined,
  217. },
  218. loading: false,
  219. tableList: [],
  220. total: 0,
  221. openOftenDialog: false,
  222. saveOftenDialog: false,
  223. openTwoBOM: false,
  224. oftenTableList: [],
  225. composeQuery: {
  226. pageNum: 1,
  227. pageSize: 9999,
  228. name: '',
  229. },
  230. pathPrefix: process.env.VUE_APP_IMG_URL,
  231. saveForm: {
  232. name: '',
  233. bomCombinationDetailsList: [],
  234. },
  235. rules: {
  236. name: [{ required: true, message: '请输入常用包材配组合名称', trigger: 'blur' }],
  237. quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
  238. },
  239. packingFittings: [],
  240. form: {
  241. selectData: [],
  242. },
  243. openBOM: false,
  244. specCode: '',
  245. }
  246. },
  247. created() {
  248. categoryList({ categoryType: '3' }).then((res) => {
  249. this.packingFittings = this.packingFittings.concat(res.data.data)
  250. categoryList({ categoryType: '2' }).then((res) => {
  251. this.packingFittings = this.packingFittings.concat(res.data.data)
  252. })
  253. })
  254. },
  255. mounted() {
  256. this.getList()
  257. },
  258. computed: mapGetters(['userInfo']),
  259. methods: {
  260. getList() {
  261. this.loading = true
  262. API.batchReplaceList(this.queryParams).then(
  263. (res) => {
  264. this.tableList = res.data.data.records
  265. this.total = res.data.data.total
  266. this.loading = false
  267. this.$nextTick(() => {
  268. this.$refs.table.doLayout()
  269. })
  270. },
  271. (err) => {
  272. console.log('batchReplaceList: ' + err)
  273. this.loading = false
  274. }
  275. )
  276. },
  277. /** 搜索按钮操作 */
  278. handleQuery() {
  279. this.queryParams.pageNum = 1
  280. this.getList()
  281. },
  282. /** 重置按钮操作 */
  283. resetQuery() {
  284. this.resetForm('queryForm')
  285. this.handleQuery()
  286. },
  287. handleBOM() {
  288. this.openBOM = true
  289. },
  290. handleOpenOftenDialog() {
  291. this.handleGetList()
  292. this.openOftenDialog = true
  293. },
  294. openSaveOftenDialog() {
  295. if (this.form.selectData && this.form.selectData.length > 0) {
  296. let packing = this.form.selectData.filter((item) => item.categoryId)
  297. if (!(packing && packing.length > 0)) {
  298. return this.msgInfo('请选择包材配件')
  299. }
  300. } else {
  301. return this.msgInfo('请选择包材配件')
  302. }
  303. this.saveOftenDialog = true
  304. },
  305. handleOpenTwoBOM() {
  306. this.openTwoBOM = true
  307. },
  308. handleGetList() {
  309. list(this.composeQuery).then((res) => {
  310. this.oftenTableList = res.data.data
  311. })
  312. },
  313. resetGetList() {
  314. this.resetForm('composeForm')
  315. this.handleGetList()
  316. },
  317. openFile(path) {
  318. window.open(path)
  319. },
  320. removeCompose(id) {
  321. this.$confirm('是否确认删除此条包材组合?', '警告', {
  322. confirmButtonText: '确定',
  323. cancelButtonText: '取消',
  324. type: 'warning',
  325. }).then(() => {
  326. del({ id }).then(() => {
  327. this.msgSuccess('删除成功!')
  328. this.handleGetList()
  329. })
  330. })
  331. },
  332. selectCompose(row) {
  333. const list = row.bomCombinationDetailsList
  334. let arr = list.map((item) => {
  335. return {
  336. bomColorName: item.bomColorName,
  337. specCode: item.bomColorspecCode,
  338. bomId: item.bomId,
  339. quantity: Number(item.singleQuantity),
  340. id: item.bomColorId,
  341. price: item.price,
  342. categoryId: item.categoryId,
  343. }
  344. })
  345. this.form.selectData = arr
  346. this.msgSuccess('选择完成')
  347. },
  348. saveCancel() {
  349. this.saveOftenDialog = false
  350. this.saveForm = {
  351. name: '',
  352. bomCombinationDetailsList: [],
  353. }
  354. },
  355. saveOften() {
  356. this.$refs['saveForm'].validate((valid) => {
  357. if (valid) {
  358. let arr = this.form.selectData.map((item) => ({ bomColorId: item.bomId, singleQuantity: item.quantity, price: item.price }))
  359. this.saveForm.bomCombinationDetailsList = arr
  360. save(this.saveForm).then(() => {
  361. this.msgSuccess('保存成功!')
  362. this.saveCancel()
  363. })
  364. }
  365. })
  366. },
  367. getLabel(row, item) {
  368. let text = ''
  369. if (row.mountingsList && row.mountingsList.length > 0) {
  370. let data = row.mountingsList.filter((mountings) => mountings.categoryId === item.id)
  371. if (data && data.length > 0) {
  372. text = data[0].bomColorCode
  373. }
  374. }
  375. return text
  376. },
  377. handleSelectTwoBOM(data, index) {
  378. if (this.form.selectData && this.form.selectData.length > 0) {
  379. let packing = this.form.selectData.filter((item) => item.categoryId)
  380. if (!(packing && packing.length > 0)) {
  381. this.form.selectData = []
  382. }
  383. }
  384. let row = data.bomColors[index]
  385. let item = {
  386. bomColorName: row.nameChinese,
  387. specCode: row.specCode,
  388. id: data.id,
  389. bomId: row.id,
  390. quantity: undefined,
  391. price: row.price,
  392. }
  393. this.form.selectData.push(item)
  394. this.msgSuccess('添加完成')
  395. },
  396. handleDelete(index) {
  397. this.form.selectData.splice(index, 1)
  398. },
  399. clickReset() {
  400. this.form.selectData = []
  401. },
  402. clickReplace() {
  403. this.$refs['ruleForm'].validate((valid) => {
  404. if (valid) {
  405. if (this.form.selectData && this.form.selectData.length > 0) {
  406. this.$confirm('是否确认替换所有包材配件?', '警告', {
  407. confirmButtonText: '确定',
  408. cancelButtonText: '取消',
  409. type: 'warning',
  410. })
  411. .then(() => {
  412. let type = 10
  413. if (this.userInfo.subsidiaryId) {
  414. type = 20
  415. }
  416. API.batchReplace({ type: type, bomColorList: this.form.selectData, productColor: this.queryParams }).then(() => {
  417. this.msgSuccess('替换成功!')
  418. this.handleQuery()
  419. })
  420. })
  421. .catch(() => {})
  422. } else {
  423. this.msgInfo('请选择BOM或包材配件')
  424. }
  425. }
  426. })
  427. },
  428. handleSelectBOM(data, index) {
  429. let row = data.bomColors[index]
  430. this.form.selectData = [
  431. {
  432. bomColorName: row.nameChinese,
  433. specCode: row.specCode,
  434. id: row.id,
  435. bomId: data.id,
  436. quantity: undefined,
  437. price: row.price,
  438. },
  439. ]
  440. this.msgSuccess('选择完成')
  441. this.openBOM = false
  442. },
  443. clickRemove() {
  444. if (this.specCode) {
  445. this.$confirm('是否确认移除?', '警告', {
  446. confirmButtonText: '确定',
  447. cancelButtonText: '取消',
  448. type: 'warning',
  449. })
  450. .then(() => {
  451. API.touchRemove({ bomColorCode: this.specCode, productColor: this.queryParams }).then(() => {
  452. this.msgSuccess('移除成功!')
  453. this.specCode = ''
  454. this.handleQuery()
  455. })
  456. })
  457. .catch(() => {})
  458. } else {
  459. this.msgInfo('请输入要移除的BOM品号')
  460. }
  461. },
  462. },
  463. }
  464. </script>
  465. <style lang="scss" scoped>
  466. * {
  467. font-size: 12px;
  468. }
  469. .searchBtn {
  470. background: #20b2aa;
  471. color: #fff;
  472. border: 1px solid #20b2aa;
  473. }
  474. ::v-deep {
  475. .el-input__inner {
  476. border-radius: 1px;
  477. }
  478. .el-button--small {
  479. border-radius: 1px;
  480. }
  481. .tableHeader th {
  482. background-color: #edf0f5;
  483. height: 35px;
  484. padding: 0;
  485. }
  486. }
  487. </style>