ProductMaterialOne.vue 31 KB

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