ProductMaterial.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <template>
  2. <div style="padding: 20px 10px 0 0">
  3. <el-form ref="ruleForm" :model="form" :rules="formRules" label-width="100px">
  4. <el-form-item label="品牌:">
  5. <span>{{ form.brandName }}</span>
  6. </el-form-item>
  7. <el-row>
  8. <el-col :span="12">
  9. <el-form-item label="材质:" prop="materialChinese">
  10. <el-input v-model="form.materialChinese" placeholder="请输入材质" size="small"></el-input>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="12">
  14. <el-form-item label="型号:" prop="productModelChinese">
  15. <el-input v-model="form.productModelChinese" placeholder="请输入型号" size="small"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. </el-row>
  19. <el-form-item label="规格:" required class="color">
  20. <el-button size="mini" type="primary" @click="handleAddColor">添加规格</el-button>
  21. </el-form-item>
  22. <div style="padding-left: 80px">
  23. <el-table
  24. :data="form.colors"
  25. :cell-style="{ padding: '0' }"
  26. :row-style="{ height: '35px' }"
  27. v-loading="loading"
  28. header-row-class-name="tableHeader"
  29. :cell-class-name="cellClassName"
  30. >
  31. <el-table-column type="expand" v-if="form.id">
  32. <template slot-scope="props">
  33. <div style="padding: 8px 20px 0px">
  34. <el-row :gutter="10">
  35. <el-col :span="12">
  36. <div style="display: flex; margin-bottom: 10px">
  37. <el-button size="mini" type="primary" @click="handleOpenOftenDialog(props.$index)">选择常用包材</el-button>
  38. <el-button size="mini" type="primary" style="background: #20b2aa; border-color: #20b2aa" @click="openSaveOftenDialog(props.$index)"
  39. >保存常用包材</el-button
  40. >
  41. <el-button size="mini" type="primary" @click="handleOpenTwoBOM(props.$index)">选择包材配件</el-button>
  42. </div>
  43. <el-table :data="props.row.mountingsList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }" border ref="table">
  44. <el-table-column label="数量" width="160">
  45. <template slot-scope="scope">
  46. <el-form-item
  47. label-width="0px"
  48. :prop="'colors.' + props.$index + '.mountingsList.' + scope.$index + '.quantity'"
  49. :rules="formRules.quantity"
  50. class="input"
  51. >
  52. <el-input-number
  53. style="width: 100%"
  54. size="mini"
  55. v-model="scope.row.quantity"
  56. :controls="false"
  57. :min="1"
  58. :max="10000000"
  59. :precision="0"
  60. />
  61. </el-form-item>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="名称" prop="bomColorName" min-width="150" />
  65. <el-table-column label="操作" align="center" width="80" fixed="right">
  66. <template slot-scope="scope">
  67. <span
  68. class="el-icon-remove-outline"
  69. style="font-size: 16px; cursor: pointer; color: #d9001b"
  70. @click="removeTwoBOM(props.$index, scope.$index)"
  71. ></span>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </el-col>
  76. <el-col :span="12">
  77. <div style="display: flex; margin-bottom: 10px">
  78. <el-button size="mini" type="primary" @click="clickSelectBOM(props.$index)">选择快递包装</el-button>
  79. </div>
  80. <el-table :data="props.row.exPackList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }" border ref="table">
  81. <el-table-column label="数量" width="130">
  82. <template slot-scope="scope">
  83. <el-form-item
  84. label-width="0px"
  85. :prop="'colors.' + props.$index + '.exPackList.' + scope.$index + '.quantity'"
  86. :rules="formRules.quantity"
  87. class="input"
  88. >
  89. <el-input-number
  90. style="width: 100%"
  91. size="mini"
  92. v-model="scope.row.quantity"
  93. :controls="false"
  94. :min="1"
  95. :max="10000000"
  96. :precision="0"
  97. />
  98. </el-form-item>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="名称" prop="bomColorName" min-width="140" />
  102. <el-table-column label="操作" align="center" width="80" fixed="right">
  103. <template slot-scope="scope">
  104. <span
  105. class="el-icon-remove-outline"
  106. style="font-size: 16px; cursor: pointer; color: #d9001b"
  107. @click="removePackingBOM(props.$index, scope.$index)"
  108. ></span>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. </el-col>
  113. </el-row>
  114. </div>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="规格图" align="center" width="70">
  118. <template slot-scope="scope">
  119. <el-upload
  120. class="avatar-uploader"
  121. :action="action"
  122. :headers="{ 'Blade-Auth': token }"
  123. :show-file-list="false"
  124. :before-upload="beforeAvatarUpload"
  125. :on-success="
  126. (response, file, fileList) => {
  127. return uploadSuccess(response, file, fileList, scope.$index)
  128. }
  129. "
  130. :on-error="
  131. (err, file, fileList) => {
  132. return uploadError(err, file, fileList, scope.$index)
  133. }
  134. "
  135. :on-progress="
  136. (event, file, fileList) => {
  137. return uploadProgress(event, file, fileList, scope.$index)
  138. }
  139. "
  140. :disabled="scope.row.loading"
  141. accept=".jpg, .png, .jpeg"
  142. >
  143. <div v-loading="scope.row.loading">
  144. <div v-if="scope.row.colorAccessory">
  145. <img
  146. v-if="!scope.row.colorAccessory.includes('https')"
  147. :src="pathPrefix + scope.row.colorAccessory"
  148. class="productImg"
  149. style="width: 50px; height: 50px"
  150. />
  151. <img v-else class="productImg" style="width: 50px; height: 50px" :src="scope.row.colorAccessory" />
  152. </div>
  153. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  154. </div>
  155. </el-upload>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="设计图" align="center" width="70">
  159. <template slot-scope="scope">
  160. <el-upload
  161. class="avatar-uploader"
  162. :action="action"
  163. :headers="{ 'Blade-Auth': token }"
  164. :show-file-list="false"
  165. :before-upload="beforeAvatarUpload"
  166. :on-success="
  167. (response, file, fileList) => {
  168. return uploadSuccess1(response, file, fileList, scope.$index)
  169. }
  170. "
  171. :on-error="
  172. (err, file, fileList) => {
  173. return uploadError1(err, file, fileList, scope.$index)
  174. }
  175. "
  176. :on-progress="
  177. (event, file, fileList) => {
  178. return uploadProgress1(event, file, fileList, scope.$index)
  179. }
  180. "
  181. :disabled="scope.row.loading1"
  182. accept=".jpg, .png, .jpeg"
  183. >
  184. <div v-loading="scope.row.loading1">
  185. <div v-if="scope.row.designSketch">
  186. <img
  187. v-if="!scope.row.designSketch.includes('https')"
  188. :src="pathPrefix + scope.row.designSketch"
  189. class="productImg"
  190. style="width: 50px; height: 50px"
  191. />
  192. <img v-else class="productImg" style="width: 50px; height: 50px" :src="scope.row.designSketch" />
  193. </div>
  194. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  195. </div>
  196. </el-upload>
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="品号" align="left" width="170">
  200. <template slot-scope="scope">
  201. <el-form-item :prop="'colors.' + scope.$index + '.specCode'" :rules="formRules.specCode" label-width="0px">
  202. <el-input v-model="scope.row.specCode" placeholder="请输入" size="small" style="width: 100%"></el-input>
  203. </el-form-item>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="品名" align="left" min-width="200">
  207. <template slot-scope="scope">
  208. <el-form-item :prop="'colors.' + scope.$index + '.nameChinese'" :rules="formRules.nameChinese" label-width="0px">
  209. <el-input v-model="scope.row.nameChinese" placeholder="请输入" size="small" style="width: 100%"></el-input>
  210. </el-form-item>
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="加工版面" align="left" width="140">
  214. <template slot-scope="scope">
  215. <el-form-item label-width="0px">
  216. <el-select v-model="scope.row.processingLayout" placeholder="请选择加工版面" size="small" style="width: 100%">
  217. <el-option v-for="item in processingLayout" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  218. </el-select>
  219. </el-form-item>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="尺寸(长宽高,cm)" align="left" width="240">
  223. <template slot-scope="scope">
  224. <el-row>
  225. <el-col :span="8">
  226. <el-form-item :prop="'colors.' + scope.$index + '.length'" :rules="formRules.length" label-width="0px">
  227. <el-input v-model="scope.row.length" placeholder="长" size="small" style="width: 70%"></el-input>
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="8">
  231. <el-form-item :prop="'colors.' + scope.$index + '.width'" :rules="formRules.width" label-width="0px">
  232. <el-input v-model="scope.row.width" placeholder="宽" size="small" style="width: 70%"></el-input>
  233. </el-form-item>
  234. </el-col>
  235. <el-col :span="8">
  236. <el-form-item :prop="'colors.' + scope.$index + '.height'" :rules="formRules.height" label-width="0px">
  237. <el-input v-model="scope.row.height" placeholder="高" size="small" style="width: 70%"></el-input>
  238. </el-form-item>
  239. </el-col>
  240. </el-row>
  241. </template>
  242. </el-table-column>
  243. <el-table-column label="净重(g)" align="left" width="100">
  244. <template slot-scope="scope">
  245. <el-form-item :prop="'colors.' + scope.$index + '.weight'" :rules="formRules.weight" label-width="0px">
  246. <el-input v-model="scope.row.weight" placeholder="净重" size="small" style="width: 90%"></el-input>
  247. </el-form-item>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="共享文件夹" align="left" width="100">
  251. <template slot-scope="scope">
  252. <span style="color: #027db4; cursor: pointer" @click="handleClickUpload(scope.row.artworkDocument)">上传ez3/dxf</span>
  253. </template>
  254. </el-table-column>
  255. <el-table-column label="BOM" align="left" width="250">
  256. <template slot-scope="scope">
  257. <div>
  258. <el-button
  259. v-if="!scope.row.bomList.length > 0"
  260. type="primary"
  261. size="mini"
  262. @click="handleOpen(scope.$index)"
  263. style="margin: 5px 0; background-color: #43b214; border-color: #43b214"
  264. >选择BOM</el-button
  265. >
  266. <div v-for="(item, index) in scope.row.bomList" :key="index" style="display: flex; align-items: center">
  267. <span class="el-icon-remove-outline" style="font-size: 16px; cursor: pointer" @click="removeBOM(index, scope.$index)"></span>
  268. <img
  269. v-if="item.magPath"
  270. :src="pathPrefix + item.magPath"
  271. class="productImg"
  272. style="margin: 0px 10px; width: 36px; height: 36px"
  273. @click="openFile(pathPrefix + item.magPath)"
  274. />
  275. <span>{{ item.bomColorName }}</span>
  276. </div>
  277. </div>
  278. </template>
  279. </el-table-column>
  280. <el-table-column label="操作" width="60" align="center" fixed="right">
  281. <template slot-scope="scope">
  282. <el-button type="text" @click="handleDelete(scope.row, scope.$index)">删除</el-button>
  283. </template>
  284. </el-table-column>
  285. </el-table>
  286. </div>
  287. </el-form>
  288. <!-- 选择BOM -->
  289. <el-dialog title="选择BOM" v-if="openBOM" top="50px" :visible.sync="openBOM" width="90%" append-to-body center>
  290. <SelectBOM @selectBOM="handleSelectBOM" ref="SelectBOM"></SelectBOM>
  291. <span slot="footer" class="dialog-footer">
  292. <el-button @click="openBOM = false">关 闭</el-button>
  293. </span>
  294. </el-dialog>
  295. <el-dialog v-if="openOftenDialog" :visible.sync="openOftenDialog" title="选择常用包材" width="60%" append-to-body>
  296. <el-form :model="composeQuery" ref="composeForm" :inline="true">
  297. <el-form-item label="组合名称" prop="name">
  298. <el-input placeholder="请输入" v-model="composeQuery.name" clearable size="small" @keyup.enter.native="handleQuery" />
  299. </el-form-item>
  300. <el-form-item>
  301. <el-button size="mini" @click="handleQuery" class="searchBtn">搜索</el-button>
  302. <el-button size="mini" @click="resetQuery">重置</el-button>
  303. </el-form-item>
  304. </el-form>
  305. <div class="compose-table">
  306. <el-table :data="oftenTableList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }" header-row-class-name="tableHeader">
  307. <el-table-column type="expand" align="left" width="50">
  308. <template slot-scope="scope">
  309. <div>
  310. <el-table :data="scope.row.bomCombinationDetailsList" size="small" :row-style="{ height: '35px' }" :cell-style="{ padding: '0' }">
  311. <el-table-column label="主图" width="80" align="center">
  312. <template slot-scope="scope">
  313. <div v-if="scope.row.magPath">
  314. <img class="img" :src="pathPrefix + scope.row.magPath" @click="openFile(pathPrefix + scope.row.magPath)" />
  315. </div>
  316. </template>
  317. </el-table-column>
  318. <el-table-column label="品号" prop="bomColorspecCode" />
  319. <el-table-column label="品名" prop="bomColorName" />
  320. <el-table-column label="数量" prop="singleQuantity" width="80" />
  321. <el-table-column label="单价¥" prop="price" width="80" align="right" />
  322. </el-table>
  323. </div>
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="组合名称" prop="name" align="left" />
  327. <el-table-column label="操作" align="center" width="120" fixed="right">
  328. <template slot-scope="scope">
  329. <el-button type="text" @click="removeCompose(scope.row.id)">删 除</el-button>
  330. <el-button type="text" @click="selectCompose(scope.row)">选择</el-button>
  331. </template>
  332. </el-table-column>
  333. </el-table>
  334. </div>
  335. <el-row style="text-align: center; margin-top: 30px">
  336. <el-button size="small" @click="openOftenDialog = false">取 消</el-button>
  337. </el-row>
  338. </el-dialog>
  339. <el-dialog v-if="saveOftenDialog" :visible.sync="saveOftenDialog" title="保存常用包材" width="40%" append-to-body>
  340. <el-form label-width="120px" :model="saveForm" ref="saveForm" :rules="rules">
  341. <el-form-item label="常用包材名称:" prop="name">
  342. <el-input v-model="saveForm.name" placeholder="请输入"> </el-input>
  343. </el-form-item>
  344. </el-form>
  345. <el-row style="text-align: center; margin-top: 30px">
  346. <el-button size="small" @click="saveCancel">取 消</el-button>
  347. <el-button size="small" type="primary" @click="saveOften">保 存</el-button>
  348. </el-row>
  349. </el-dialog>
  350. <!-- 选择包材配件-->
  351. <el-dialog title="选择包材配件" v-if="openTwoBOM" top="50px" :visible.sync="openTwoBOM" width="90%" append-to-body center>
  352. <SelectBOM @selectBOM="handleSelectTwoBOM" showType="parts" ref="SelectBOM"></SelectBOM>
  353. <span slot="footer" class="dialog-footer">
  354. <el-button @click="openTwoBOM = false">关 闭</el-button>
  355. </span>
  356. </el-dialog>
  357. <el-dialog title="选择快递包装" v-if="openSelect" :visible.sync="openSelect" width="80%" append-to-body>
  358. <SelectPackingBOM @handleSelect="handlePackingSelect"></SelectPackingBOM>
  359. </el-dialog>
  360. </div>
  361. </template>
  362. <script>
  363. import { mapGetters } from 'vuex'
  364. import SelectBOM from '@/components/shengde/SelectBOM/index'
  365. import SelectPackingBOM from '@/views/shengde/productionSystem/production/order/selectBOM'
  366. import { addColor, removeColor, addFolder } from '@/api/product/customProductLibrary'
  367. import { list, del, save } from '@/api/shengde/subsidiary/compose/index.js'
  368. export default {
  369. name: 'ProductMaterial',
  370. props: {
  371. form: Object,
  372. },
  373. components: { SelectBOM, SelectPackingBOM },
  374. data() {
  375. const checkRewardKey = (rule, value, callback) => {
  376. if (/[\u4E00-\u9FA5]/g.test(value)) {
  377. callback(new Error('不能输入汉字'))
  378. } else {
  379. callback()
  380. }
  381. }
  382. return {
  383. action: process.env.VUE_APP_ACTION_URL,
  384. pathPrefix: process.env.VUE_APP_IMG_URL,
  385. filePrefix: process.env.VUE_APP_FILE_PREFIX,
  386. formRules: {
  387. productModel: [{ required: true, message: '请输入型号(EN)', trigger: 'blur' }],
  388. productLong: [{ required: true, message: '请输入长(CM)', trigger: 'blur' }],
  389. productWide: [{ required: true, message: '请输入宽(CM)', trigger: 'blur' }],
  390. productHigh: [{ required: true, message: '请输入高(CM)', trigger: 'blur' }],
  391. length: [{ required: true, message: '长', trigger: 'blur' }],
  392. width: [{ required: true, message: '宽', trigger: 'blur' }],
  393. height: [{ required: true, message: '高', trigger: 'blur' }],
  394. weight: [{ required: true, message: '净重(g)', trigger: 'blur' }],
  395. code: [{ required: true, message: '请输入', trigger: 'blur' }],
  396. specCode: [
  397. { required: true, message: '请输入品号', trigger: 'blur' },
  398. { validator: checkRewardKey, trigger: 'blur' },
  399. ],
  400. nameChinese: [{ required: true, message: '请输入品名', trigger: 'blur' }],
  401. quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
  402. },
  403. loading: false,
  404. openBOM: false,
  405. rowIndex: null,
  406. oftenTableList: [],
  407. selectIndex: undefined,
  408. openOftenDialog: false,
  409. saveOftenList: [],
  410. saveOftenDialog: false,
  411. openTwoBOM: false,
  412. composeQuery: {
  413. name: '',
  414. pageSize: 999,
  415. pageNum: 1,
  416. },
  417. saveForm: {
  418. name: '',
  419. bomCombinationDetailsList: [],
  420. },
  421. rules: {
  422. name: [{ required: true, message: '请输入常用包材配组合名称', trigger: 'blur' }],
  423. },
  424. openSelect: false,
  425. selectPackingIndex: 0,
  426. processingLayout: [],
  427. }
  428. },
  429. created() {
  430. this.processingLayout = this.dictData.filter((item) => item.code === 'processing_layout')[0].children
  431. },
  432. mounted() {},
  433. computed: mapGetters(['token', 'dictData']),
  434. methods: {
  435. handleAddColor() {
  436. this.loading = true
  437. addColor().then(
  438. (res) => {
  439. let path = res.data.data.replace(/\//g, '\\')
  440. this.form.colors.push({
  441. productId: '',
  442. nameChinese: '',
  443. colorAccessory: '',
  444. loading: false,
  445. artworkDocument: path,
  446. length: '',
  447. width: '',
  448. height: '',
  449. bomList: [],
  450. designSketch: '',
  451. mountingsList: [],
  452. exPackList: [],
  453. })
  454. this.loading = false
  455. },
  456. (err) => {
  457. console.log('addColor:' + err)
  458. this.loading = false
  459. }
  460. )
  461. },
  462. handleDelete(row, index) {
  463. this.$confirm('确认删除该行数据?', {
  464. confirmButtonText: '确定',
  465. cancelButtonText: '取消',
  466. type: 'warning',
  467. }).then(() => {
  468. this.loading = true
  469. let path = row.artworkDocument.replace(/\\/g, '/')
  470. removeColor(path).then(
  471. () => {
  472. this.form.colors.splice(index, 1)
  473. this.msgSuccess('删除成功!')
  474. this.loading = false
  475. },
  476. (err) => {
  477. console.log('removeColor:' + err)
  478. this.loading = false
  479. }
  480. )
  481. })
  482. },
  483. validateForm() {
  484. let flag = null
  485. this.$refs.ruleForm.validate((valid) => {
  486. if (valid) {
  487. if (this.form.colors.length > 0) {
  488. for (let j = 0; j < this.form.colors.length; j++) {
  489. const jele = this.form.colors[j]
  490. jele.artworkDocument = jele.artworkDocument.replace(/\\/g, '/')
  491. }
  492. flag = true
  493. } else this.msgInfo('请添加规格!')
  494. } else {
  495. flag = false
  496. }
  497. })
  498. return flag
  499. },
  500. beforeAvatarUpload(file) {
  501. let fileType = this.getFileType(file.name)
  502. if (['jpg', 'png', 'jpeg'].includes(fileType)) {
  503. const isLt5kb = file.size / 1024 < 500
  504. if (!isLt5kb) {
  505. this.$message.error('上传图片大小不能超过 500kb!')
  506. }
  507. return isLt5kb
  508. } else {
  509. this.msgInfo('请上传jpg,png,jpeg格式的文件')
  510. return false
  511. }
  512. },
  513. uploadSuccess(response, file, fileList, index) {
  514. this.form.colors[index].loading = false
  515. this.form.colors[index].colorAccessory = response.data.details.path
  516. },
  517. uploadError(response, file, fileList, index) {
  518. this.form.colors[index].loading = false
  519. },
  520. uploadProgress(event, file, fileList, index) {
  521. this.form.colors[index].loading = true
  522. },
  523. uploadSuccess1(response, file, fileList, index) {
  524. this.form.colors[index].loading1 = false
  525. this.form.colors[index].designSketch = response.data.details.path
  526. this.form.colors[index].designSketchName = response.data.details.realName
  527. },
  528. uploadError1(response, file, fileList, index) {
  529. this.form.colors[index].loading1 = false
  530. },
  531. uploadProgress1(event, file, fileList, index) {
  532. this.form.colors[index].loading1 = true
  533. },
  534. openFile(path) {
  535. window.open(path)
  536. },
  537. handleOpen(index) {
  538. this.rowIndex = index
  539. this.openBOM = true
  540. },
  541. handleSelectBOM(row, index) {
  542. // 多个bom写法
  543. // let data = row.bomColors[index]
  544. // this.form.colors[this.rowIndex].bomList.push(data)
  545. // this.msgSuccess('选择成功!')
  546. // this.openBOM=false
  547. //单个bom写法
  548. let arr = []
  549. let data = row.bomColors[index]
  550. let submitData = {
  551. id: row.id,
  552. bomColorId: data.id,
  553. bomColorName: data.nameChinese,
  554. magPath: data.magPath,
  555. }
  556. arr.push(submitData)
  557. this.form.colors[this.rowIndex].bomList = arr
  558. this.msgSuccess('选择成功!')
  559. this.openBOM = false
  560. },
  561. removeBOM(index, parentIndex) {
  562. this.$confirm('确认删除该BOM?', {
  563. confirmButtonText: '确定',
  564. cancelButtonText: '取消',
  565. type: 'warning',
  566. })
  567. .then(() => {
  568. this.form.colors[parentIndex].bomList.splice(index, 1)
  569. this.msgSuccess('删除成功!')
  570. })
  571. .catch(() => {})
  572. },
  573. handleClickUpload(item) {
  574. let path = JSON.parse(JSON.stringify(item)).replace(/\\/g, '/')
  575. addFolder(path).then(
  576. () => {
  577. let a = document.createElement('a')
  578. a.href = 'printer://' + (this.filePrefix + path).replace(/\//g, '/') + '/'
  579. a.style.display = 'none'
  580. document.body.appendChild(a)
  581. a.click()
  582. document.body.removeChild(a)
  583. },
  584. (err) => {
  585. console.log('addFolder:' + err)
  586. }
  587. )
  588. },
  589. removeTwoBOM(numOne, numTwo) {
  590. this.$confirm('确认删除该行包材配件?', {
  591. confirmButtonText: '确定',
  592. cancelButtonText: '取消',
  593. type: 'warning',
  594. }).then(() => {
  595. this.form.colors[numOne].mountingsList.splice(numTwo, 1)
  596. this.msgSuccess('删除成功!')
  597. })
  598. },
  599. handleOpenOftenDialog(index) {
  600. this.handleQuery()
  601. this.selectIndex = index
  602. this.openOftenDialog = true
  603. },
  604. openSaveOftenDialog(index) {
  605. this.saveOftenList = this.form.colors[index].mountingsList
  606. this.saveOftenDialog = true
  607. },
  608. handleOpenTwoBOM(index) {
  609. this.selectIndex = index
  610. this.openTwoBOM = true
  611. },
  612. handleQuery() {
  613. list({ name: '', pageSize: 9999, pageNum: 1 }).then((res) => {
  614. this.oftenTableList = res.data.data
  615. })
  616. },
  617. resetQuery() {
  618. this.resetForm('composeForm')
  619. this.handleQuery()
  620. },
  621. removeCompose(id) {
  622. this.$confirm('是否确认删除此条包材组合?', '警告', {
  623. confirmButtonText: '确定',
  624. cancelButtonText: '取消',
  625. type: 'warning',
  626. }).then(() => {
  627. del({ id }).then(() => {
  628. this.msgSuccess('删除成功!')
  629. this.handleQuery()
  630. })
  631. })
  632. },
  633. selectCompose(row) {
  634. const list = row.bomCombinationDetailsList
  635. let arr = list.map((item) => {
  636. return {
  637. bomColorName: item.bomColorName,
  638. bomColorId: item.bomColorId,
  639. quantity: Number(item.singleQuantity),
  640. id: item.bomId,
  641. }
  642. })
  643. this.form.colors[this.selectIndex].mountingsList = arr
  644. this.msgSuccess('选择完成')
  645. },
  646. saveCancel() {
  647. this.saveOftenDialog = false
  648. this.saveForm = {
  649. name: '',
  650. bomCombinationDetailsList: [],
  651. }
  652. },
  653. saveOften() {
  654. this.$refs['saveForm'].validate((valid) => {
  655. if (valid) {
  656. let arr = this.saveOftenList.map((item) => ({ bomColorId: item.bomColorId, singleQuantity: item.singleQuantity, price: item.price }))
  657. this.saveForm.bomCombinationDetailsList = arr
  658. save(this.saveForm).then(() => {
  659. this.msgSuccess('保存成功!')
  660. this.saveCancel()
  661. })
  662. }
  663. })
  664. },
  665. handleSelectTwoBOM(data, index) {
  666. let list = this.form.colors[this.selectIndex].mountingsList.filter((item) => item.categoryId === data.categoryId)
  667. if (list && list.length > 0) {
  668. return this.msgInfo('该类型包材配件已添加')
  669. }
  670. let row = data.bomColors[index]
  671. let item = {
  672. bomColorName: row.nameChinese,
  673. id: data.id,
  674. bomColorId: row.id,
  675. categoryId: data.categoryId,
  676. quantity: '',
  677. }
  678. this.form.colors[this.selectIndex].mountingsList.push(item)
  679. this.msgSuccess('添加完成')
  680. },
  681. clickSelectBOM(index) {
  682. this.selectPackingIndex = index
  683. this.openSelect = true
  684. },
  685. handlePackingSelect(row, rowParent) {
  686. let data = this.form.colors[this.selectPackingIndex].exPackList.filter((item) => item.bomColorId === row.id)
  687. if (data && data.length > 0) {
  688. return this.msgInfo('快递包装已选择')
  689. }
  690. this.form.colors[this.selectPackingIndex].exPackList.push({
  691. id: rowParent.id,
  692. bomColorId: row.id,
  693. quantity: undefined,
  694. bomColorName: row.nameChinese,
  695. })
  696. this.msgSuccess('选择完成')
  697. },
  698. removePackingBOM(index, indexTwo) {
  699. this.form.colors[index].exPackList.splice(indexTwo, 1)
  700. },
  701. cellClassName({ row, columnIndex }) {
  702. if (columnIndex === 0) {
  703. if (!row.id) {
  704. return 'hideClass'
  705. }
  706. }
  707. },
  708. },
  709. }
  710. </script>
  711. <style lang="scss" scoped>
  712. ::v-deep {
  713. .el-input-number {
  714. .el-input__inner {
  715. text-align: left !important;
  716. }
  717. }
  718. .el-button {
  719. border-radius: 0;
  720. }
  721. .tableHeader th {
  722. background-color: #edf0f5;
  723. height: 35px;
  724. padding: 0;
  725. }
  726. .color .el-form-item__content,
  727. .color .el-form-item__label {
  728. line-height: 32px !important;
  729. }
  730. .el-form-item__error {
  731. top: 90%;
  732. }
  733. .hideClass {
  734. .el-table__expand-icon {
  735. display: none;
  736. }
  737. }
  738. }
  739. .searchBtn {
  740. background: #20b2aa;
  741. color: #fff;
  742. border: 1px solid #20b2aa;
  743. }
  744. .productImg {
  745. width: 60px;
  746. height: 60px;
  747. cursor: pointer;
  748. object-fit: contain;
  749. vertical-align: middle;
  750. border: none;
  751. }
  752. .avatar-uploader-icon {
  753. margin: 4px 0;
  754. font-size: 28px;
  755. color: rgb(140, 147, 157);
  756. border: 1px dashed #d9d9d9;
  757. background-color: #fbfdff;
  758. border-radius: 2px;
  759. width: 50px;
  760. height: 50px;
  761. line-height: 50px;
  762. text-align: center;
  763. &:hover {
  764. border-color: #409eff;
  765. }
  766. }
  767. </style>