product-management.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <!-- BOM清单 -->
  2. <template>
  3. <div class="product-management">
  4. <template
  5. v-if="!addOrUpdateVisible && !changeFormVisible && !attachVisible && !detailVisible && !craftsVisible && !drawVisible && !changeVisible && !noticeChangeVisible && !importVisible">
  6. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  7. <el-form-item label="名称/图号">
  8. <el-input v-model="dataForm.productName" placeholder="物料名称/图号" clearable />
  9. </el-form-item>
  10. <el-form-item label="物料类别">
  11. <el-select v-model="dataForm.productType" remote placeholder="请选择">
  12. <el-option v-for="item in optionsType" :key="item.code" :label="item.value" :value="item.code">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. <!-- <el-form-item label="图号">
  17. <el-input v-model="dataForm.mapNumber" placeholder="图号" clearable/>
  18. </el-form-item> -->
  19. <!-- <el-form-item label="是否组合">-->
  20. <!-- <el-select-->
  21. <!-- v-model="dataForm.isCompose"-->
  22. <!-- placeholder="请选择">-->
  23. <!-- <el-option-->
  24. <!-- v-for="item in optionsCompose"-->
  25. <!-- :key="item.value"-->
  26. <!-- :label="item.label"-->
  27. <!-- :value="item.value">-->
  28. <!-- </el-option>-->
  29. <!-- </el-select>-->
  30. <!-- </el-form-item>-->
  31. <el-form-item>
  32. <el-button @click="search()">查询</el-button>
  33. <el-button v-if="isAuth('pro:product:save')" type="primary"
  34. @click="addOrUpdateHandle(0, false)">新建</el-button>
  35. <el-button v-if="isAuth('pro:product:noteChangeConfig')" type="primary"
  36. @click="setNoticeChangeHandel()">变更通知人设置</el-button>
  37. <!-- <el-button type="primary" @click="importFromExcel">导入清单</el-button> -->
  38. <el-button type="primary" @click="templateDownload">清单模板下载</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-table ref="treeTable" :data="dataList" row-key="productId" border :indent='20' lazy :load="loadingData"
  42. v-loading="dataListLoading" @expand-change="handleExpandChange" :expand-row-keys="expandedRowKeys"
  43. @row-click="openDetail" style="width: 100%;">
  44. <el-table-column label="序号" type="index" width="50" align="center">
  45. </el-table-column>
  46. <el-table-column prop="productCode" header-align="center" align="center" width="200"
  47. :show-tooltip-when-overflow="true" label="物料编码">
  48. </el-table-column>
  49. <el-table-column prop="mapNumber" header-align="center" align="center" width="120"
  50. :show-tooltip-when-overflow="true" label="图号">
  51. </el-table-column>
  52. <el-table-column header-align="center" align="center" label="对应图纸">
  53. <template slot-scope="scope">
  54. <el-button v-if="scope.row.drawings && scope.row.drawings.length" type="text" size="small"
  55. @click="openImagePreview(scope.row.drawings)">
  56. 查看({{ scope.row.drawings.length }})
  57. </el-button>
  58. <el-button v-else type="text" size="small" disabled>
  59. 查看(0)
  60. </el-button>
  61. </template>
  62. <!-- <template slot-scope="scope">
  63. <el-button :disabled="!scope.row.proDrawings || scope.row.proDrawings.length === 0" type="text" size="small"
  64. @click="drawDetails(scope.row)">查看</el-button>
  65. </template> -->
  66. </el-table-column>
  67. <el-table-column prop="simplePic" header-align="center" align="center" min-width="120" label="简图">
  68. <template slot-scope="scope">
  69. <el-popover placement="right" title="" trigger="hover">
  70. <img :src="scope.row.simplePic" style="height: 400px;width: 500px">
  71. <img slot="reference" :src="scope.row.simplePic" :alt="scope.row.simplePic"
  72. style="max-height: 50px;max-width: 130px">
  73. </el-popover>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="productName" header-align="center" align="center" width="140"
  77. :show-tooltip-when-overflow="true" label="物料名称">
  78. </el-table-column>
  79. <el-table-column prop="importance" header-align="center" align="center" width="140"
  80. :show-tooltip-when-overflow="true" label="关重件">
  81. </el-table-column>
  82. <el-table-column prop="productSpec" header-align="center" align="center" width="140"
  83. :show-tooltip-when-overflow="true" label="物料规格">
  84. </el-table-column>
  85. <el-table-column prop="productType" header-align="center" align="center" min-width="120" :formatter="typeFormat"
  86. label="类别">
  87. </el-table-column>
  88. <el-table-column prop="isCompose" header-align="center" align="center" min-width="80" :formatter="composeFormat"
  89. label="是否组合">
  90. </el-table-column>
  91. <el-table-column prop="materials" header-align="center" align="center" width="140"
  92. :show-tooltip-when-overflow="true" label="材料">
  93. </el-table-column>
  94. <el-table-column prop="cnt" header-align="center" align="center" label="单套数量">
  95. </el-table-column>
  96. <el-table-column prop="unit" header-align="center" align="center" label="单位">
  97. </el-table-column>
  98. <el-table-column prop="size" header-align="center" align="center" label="物料尺寸">
  99. </el-table-column>
  100. <el-table-column prop="developedSize" header-align="center" align="center" width="100"
  101. :show-tooltip-when-overflow="true" label="展开尺寸">
  102. </el-table-column>
  103. <el-table-column prop="surfaceTreatment" header-align="center" align="center" width="100"
  104. :show-tooltip-when-overflow="true" label="表面处理">
  105. </el-table-column>
  106. <el-table-column prop="heatTreatment" header-align="center" align="center" width="100"
  107. :show-tooltip-when-overflow="true" label="热处理">
  108. </el-table-column>
  109. <el-table-column prop="sourceName" header-align="center" align="center" width="160"
  110. :show-overflow-tooltip="true" label="来源">
  111. </el-table-column>
  112. <el-table-column header-align="center" align="center" width="140" :show-overflow-tooltip="true" label="更改说明">
  113. <template slot-scope="scope">
  114. <span>{{ scope.row.noticeChangeRecord ? scope.row.noticeChangeRecord.description : '' }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column header-align="center" align="center" label="更改单">
  118. <template slot-scope="scope">
  119. <el-button
  120. :disabled="!scope.row.noticeChangeRecord || !scope.row.noticeChangeRecord.attachList || scope.row.noticeChangeRecord.attachList.length === 0"
  121. type="text" size="small" @click="changeDetails(scope.row)">查看</el-button>
  122. </template>
  123. </el-table-column>
  124. <el-table-column header-align="center" align="center" label="技术文件">
  125. <template slot-scope="scope">
  126. <el-button :disabled="!scope.row.attachList || scope.row.attachList.length === 0" type="text" size="small"
  127. @click="attachDetails(scope.row)">查看</el-button>
  128. </template>
  129. </el-table-column>
  130. <el-table-column header-align="center" align="center" label="物料配料清单">
  131. <template slot-scope="scope">
  132. <el-button :disabled="!scope.row.listingList || scope.row.listingList.length === 0" type="text" size="small"
  133. @click="attachDetails2(scope.row)">查看</el-button>
  134. </template>
  135. </el-table-column>
  136. <el-table-column header-align="center" align="center" label="对应工艺">
  137. <template slot-scope="scope">
  138. <el-button :disabled="!scope.row.techId" type="text" size="small"
  139. @click="techDetails(scope.row.techId)">查看</el-button>
  140. </template>
  141. </el-table-column>
  142. <el-table-column prop="createTime" header-align="center" align="center" min-width="160" label="创建时间">
  143. </el-table-column>
  144. <el-table-column prop="creatorName" header-align="center" align="center" min-width="100" label="创建人">
  145. </el-table-column>
  146. <el-table-column prop="notes" header-align="center" align="center" min-width="180" :show-overflow-tooltip="true"
  147. label="备注">
  148. </el-table-column>
  149. <el-table-column fixed="right" header-align="center" align="center" min-width="80" :formatter="formatState"
  150. :show-overflow-tooltip="true" label="状态">
  151. </el-table-column>
  152. <el-table-column fixed="right" header-align="center" align="center" min-width="80" :formatter="formatReadState"
  153. :show-overflow-tooltip="true" label="读写状态">
  154. </el-table-column>
  155. <el-table-column fixed="right" header-align="center" align="center" width="170" label="操作">
  156. <template slot-scope="scope">
  157. <el-button v-if="isAuth('pro:product:synchronization') && (!scope.row.materialId || false)" type="text"
  158. size="small" @click="syncHandle(scope.row.productId)">同步仓库</el-button>
  159. <el-button v-if="isAuth('pro:product:info')" type="text" size="small"
  160. @click="detailHandle(scope.row.productId)">查看</el-button>
  161. <el-button v-if="isAuth('pro:product:update')" type="text" size="small"
  162. @click="addOrUpdateHandle(scope.row.productId, false)">编辑</el-button>
  163. <el-button v-if="isAuth('pro:product:change')" type="text" size="small"
  164. @click="changeHandle(scope.row.productId)">变更</el-button>
  165. <el-button v-if="isAuth('pro:product:read') && Number(scope.row.writeState) === 2" type="text" size="small"
  166. @click="readHandle(scope.row.productId)">只读</el-button>
  167. <el-button v-if="isAuth('pro:product:write') && Number(scope.row.writeState) === 1" type="text" size="small"
  168. @click="writeHandle(scope.row.productId)">读写</el-button>
  169. <el-button v-if="isAuth('pro:product:pause') && Number(scope.row.state) === 1" type="text" size="small"
  170. @click="pauseHandle(scope.row.productId)">暂停生产</el-button>
  171. <el-button v-if="isAuth('pro:product:regain') && Number(scope.row.state) === 2" type="text" size="small"
  172. @click="regainHandle(scope.row.productId)">恢复生产</el-button>
  173. <el-button v-if="isAuth('pro:product:delete')" style="color: red" type="text" size="small"
  174. @click="deleteHandle(scope.row.productId)">删除</el-button>
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  179. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  180. layout="total, sizes, prev, pager, next, jumper">
  181. </el-pagination>
  182. </template>
  183. <!-- 弹窗, 新增 / 修改 -->
  184. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
  185. @onChose="onChose"></add-or-update>
  186. <detail v-if="detailVisible" ref="detail" @onChose="onChose" />
  187. <crafts-detail v-if="craftsVisible" ref="craftsDetail" @onChose="onChose" />
  188. <product-draw-detail v-if="drawVisible" ref="drawDetail" @onChose="onChose" />
  189. <attach-detail v-if="changeVisible" ref="changeDetail" @onChose="onChose" />
  190. <attach-detail v-if="attachVisible" ref="attachDetail" @onChose="onChose" />
  191. <notice-change-setting v-if="noticeChangeVisible" ref="noticeChangeSetting" @onChose="onChose" />
  192. <change-form v-if="changeFormVisible" ref="changeForm" @refreshDataList="getDataList" @onChose="onChose" />
  193. <el-dialog title="导入清单" :visible.sync="importVisible">
  194. <el-upload class="upload-demo" ref="upload" :on-remove="handleRemove" action="#" :limit="1" :file-list="fileList"
  195. :auto-upload="false" :http-request="handleUpload" v-loading="importLoading">
  196. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  197. <el-button size="small" type="success" @click="submitUpload">开始上传</el-button>
  198. </el-upload>
  199. </el-dialog>
  200. <image-preview ref="imagePreview" />
  201. </div>
  202. </template>
  203. <script>
  204. import Vue from 'vue'
  205. import AddOrUpdate from './product-add-or-update'
  206. import Detail from './product-detail'
  207. import { getDictList } from '@/api/dict'
  208. import { getProductList, getChildren } from '@/api/product'
  209. import CraftsDetail from './crafts-detail'
  210. import ProductDrawDetail from './product-draw-detail'
  211. import AttachDetail from '../common/attach-detail'
  212. import NoticeChangeSetting from './product-notice-change-setting'
  213. import ChangeForm from './product-change'
  214. import { bomStateOption, writeStateOption, optionsCompose } from '@/utils/enums'
  215. import UploadComponent from '@/views/modules/common/upload-component-v2'
  216. import { downloadUrl } from '@/api/file'
  217. import ImagePreview from '@/views/modules/common/image-preview.vue'
  218. import ImageViewerMixin from '@/views/modules/common/mixins/image-viewer-mixin'
  219. export default {
  220. name: 'product-management',
  221. mixins: [ImageViewerMixin],
  222. components: {
  223. AttachDetail,
  224. ProductDrawDetail,
  225. CraftsDetail,
  226. AddOrUpdate,
  227. Detail,
  228. NoticeChangeSetting,
  229. ChangeForm,
  230. UploadComponent,
  231. ImagePreview
  232. },
  233. data() {
  234. return {
  235. addOrUpdateVisible: false,
  236. attachVisible: false,
  237. detailVisible: false,
  238. craftsVisible: false,
  239. drawVisible: false,
  240. changeVisible: false,
  241. noticeChangeVisible: false,
  242. changeFormVisible: false,
  243. importVisible: false,
  244. dataForm: {},
  245. dataList: [],
  246. pageIndex: 1,
  247. pageSize: 10,
  248. totalPage: 0,
  249. dataListLoading: false,
  250. dataListSelections: [],
  251. optionsType: [],
  252. bomStateOption: bomStateOption,
  253. writeStateOption: writeStateOption,
  254. optionsCompose: optionsCompose,
  255. importForm: {},
  256. importLoading: false,
  257. fileList: [],
  258. expandedRowKeys: [], // 展开行的key数组
  259. treeMap: new Map()
  260. }
  261. },
  262. created() {
  263. this.getTypeList()
  264. // this.getStateList()
  265. this.getDataList()
  266. },
  267. methods: {
  268. onChose() {
  269. this.addOrUpdateVisible = false
  270. this.attachVisible = false
  271. this.detailVisible = false
  272. this.craftsVisible = false
  273. this.drawVisible = false
  274. this.changeVisible = false
  275. this.noticeChangeVisible = false
  276. this.changeFormVisible = false
  277. },
  278. // 获取物料类别字典
  279. getTypeList() {
  280. getDictList({ type: 'product_type' }).then(({ data }) => {
  281. if (data) {
  282. this.optionsType = data
  283. }
  284. })
  285. },
  286. // 查询
  287. search() {
  288. this.pageIndex = 1
  289. this.getDataList()
  290. },
  291. // 获取数据列表
  292. getDataList() {
  293. this.dataListLoading = true
  294. this.addOrUpdateVisible = false
  295. let params = {
  296. ...this.dataForm,
  297. 'current': this.pageIndex,
  298. 'size': this.pageSize
  299. }
  300. getProductList(params).then(({ data }) => {
  301. if (data && data.code === '200') {
  302. this.dataList = data.data.records
  303. // this.dataList = JSON.parse(JSON.stringify(data.data.records).replace(/"children":null/g, '"children":[]'))
  304. // 简图格式调整
  305. this.dataList.forEach(item => {
  306. if (item.attachList2 && item.attachList2.length > 0) {
  307. item.simplePic = downloadUrl + item.attachList2[0].url
  308. } else {
  309. item.simplePic = ''
  310. }
  311. })
  312. this.totalPage = Number(data.data.total)
  313. } else {
  314. this.dataList = []
  315. this.totalPage = 0
  316. }
  317. this.dataListLoading = false
  318. })
  319. },
  320. deleteHandle(id) {
  321. if (!id) return
  322. let ids = []
  323. ids.push(id)
  324. this.$confirm(`确定删除?`, '提示', {
  325. confirmButtonText: '确定',
  326. cancelButtonText: '取消',
  327. type: 'warning'
  328. }).then(() => {
  329. this.$http({
  330. url: this.$http.adornUrl(`/biz-service/product/delete`),
  331. method: 'DELETE',
  332. data: ids
  333. }).then(({ data }) => {
  334. if (data && data.code === '200') {
  335. this.$message({
  336. message: '操作成功',
  337. type: 'success',
  338. duration: 1500,
  339. onClose: () => {
  340. this.getDataList()
  341. }
  342. })
  343. } else {
  344. this.$message.error(data.msg)
  345. }
  346. })
  347. }).catch(() => { })
  348. },
  349. // 每页数
  350. sizeChangeHandle(val) {
  351. this.pageSize = val
  352. this.pageIndex = 1
  353. this.getDataList()
  354. },
  355. // 当前页
  356. currentChangeHandle(val) {
  357. this.pageIndex = val
  358. this.getDataList()
  359. },
  360. // 多选
  361. selectionChangeHandle(val) {
  362. this.dataListSelections = val
  363. },
  364. // 新增 / 修改
  365. addOrUpdateHandle(id, disable) {
  366. this.addOrUpdateVisible = true
  367. this.$nextTick(() => {
  368. this.$refs.addOrUpdate.init(id, disable)
  369. })
  370. },
  371. // 变更
  372. changeHandle(id) {
  373. this.changeFormVisible = true
  374. this.$nextTick(() => {
  375. this.$refs.changeForm.init(id)
  376. })
  377. },
  378. // 转换属性“物料类别”
  379. typeFormat(row) {
  380. if (this.optionsType) {
  381. for (let i = 0; i < this.optionsType.length; i++) {
  382. if (this.optionsType[i].code === row.productType) {
  383. return this.optionsType[i].value
  384. }
  385. }
  386. }
  387. },
  388. // 转换属性“是否组合物料”
  389. composeFormat(row) {
  390. if (!row.isCompose) return ''
  391. if (Number(row.isCompose) === 1) {
  392. return '是'
  393. } else return '否'
  394. },
  395. // 详情
  396. detailHandle(id) {
  397. this.detailVisible = true
  398. this.$nextTick(() => {
  399. this.$refs.detail.init(id)
  400. })
  401. },
  402. // 变更通知人设置
  403. setNoticeChangeHandel() {
  404. this.noticeChangeVisible = true
  405. this.$nextTick(() => {
  406. this.$refs.noticeChangeSetting.init()
  407. })
  408. },
  409. // 对应图纸
  410. drawDetails(row) {
  411. this.drawVisible = true
  412. this.$nextTick(() => {
  413. this.$refs.drawDetail.init(row.proDrawings)
  414. })
  415. },
  416. // 对应工艺
  417. techDetails(id) {
  418. this.craftsVisible = true
  419. this.$nextTick(() => {
  420. this.$refs.craftsDetail.init(id)
  421. })
  422. },
  423. // 物料更改通知单
  424. changeDetails(row) {
  425. this.changeVisible = true
  426. this.$nextTick(() => {
  427. this.$refs.changeDetail.init(row.noticeChangeRecord.attachList)
  428. })
  429. },
  430. // 物料技术文件
  431. attachDetails(row) {
  432. this.attachVisible = true
  433. this.$nextTick(() => {
  434. this.$refs.attachDetail.init(row.attachList)
  435. })
  436. },
  437. // 物料配料清单附件
  438. attachDetails2(row) {
  439. this.attachVisible = true
  440. this.$nextTick(() => {
  441. this.$refs.attachDetail.init(row.listingList)
  442. })
  443. },
  444. // 状态
  445. formatState(row) {
  446. if (!row.state) return ''
  447. let option = this.bomStateOption.find(t => t.value === row.state)
  448. if (option != null) {
  449. return option.label
  450. }
  451. return ''
  452. },
  453. formatReadState(row) {
  454. if (!row.writeState) return ''
  455. let option = this.writeStateOption.find(t => t.value === row.writeState)
  456. if (option != null) {
  457. return option.label
  458. }
  459. return ''
  460. },
  461. pauseHandle(id) {
  462. if (!id) return
  463. this.$confirm(`确定暂停?`, '提示', {
  464. confirmButtonText: '确定',
  465. cancelButtonText: '取消',
  466. type: 'warning'
  467. }).then(() => {
  468. this.$http({
  469. url: this.$http.adornUrl(`/biz-service/product/pause`),
  470. method: 'POST',
  471. data: { id: id }
  472. }).then(({ data }) => {
  473. if (data && data.code === '200') {
  474. this.$message({
  475. message: '操作成功',
  476. type: 'success',
  477. duration: 1500,
  478. onClose: () => {
  479. this.getDataList()
  480. }
  481. })
  482. } else {
  483. this.$message.error(data.msg)
  484. }
  485. })
  486. }).catch(() => { })
  487. },
  488. regainHandle(id) {
  489. if (!id) return
  490. this.$confirm(`确定恢复?`, '提示', {
  491. confirmButtonText: '确定',
  492. cancelButtonText: '取消',
  493. type: 'warning'
  494. }).then(() => {
  495. this.$http({
  496. url: this.$http.adornUrl(`/biz-service/product/regain`),
  497. method: 'POST',
  498. data: { id: id }
  499. }).then(({ data }) => {
  500. if (data && data.code === '200') {
  501. this.$message({
  502. message: '操作成功',
  503. type: 'success',
  504. duration: 1500,
  505. onClose: () => {
  506. this.getDataList()
  507. }
  508. })
  509. } else {
  510. this.$message.error(data.msg)
  511. }
  512. })
  513. }).catch(() => { })
  514. },
  515. readHandle(id) {
  516. if (!id) return
  517. this.$confirm(`确定只读?`, '提示', {
  518. confirmButtonText: '确定',
  519. cancelButtonText: '取消',
  520. type: 'warning'
  521. }).then(() => {
  522. this.$http({
  523. url: this.$http.adornUrl(`/biz-service/product/read`),
  524. method: 'POST',
  525. data: { id: id }
  526. }).then(({ data }) => {
  527. if (data && data.code === '200') {
  528. this.$message({
  529. message: '操作成功',
  530. type: 'success',
  531. duration: 1500,
  532. onClose: () => {
  533. this.getDataList()
  534. }
  535. })
  536. } else {
  537. this.$message.error(data.msg)
  538. }
  539. })
  540. }).catch(() => { })
  541. },
  542. writeHandle(id) {
  543. if (!id) return
  544. this.$confirm(`确定读写?`, '提示', {
  545. confirmButtonText: '确定',
  546. cancelButtonText: '取消',
  547. type: 'warning'
  548. }).then(() => {
  549. this.$http({
  550. url: this.$http.adornUrl(`/biz-service/product/write`),
  551. method: 'POST',
  552. data: { id: id }
  553. }).then(({ data }) => {
  554. if (data && data.code === '200') {
  555. this.$message({
  556. message: '操作成功',
  557. type: 'success',
  558. duration: 1500,
  559. onClose: () => {
  560. this.getDataList()
  561. }
  562. })
  563. } else {
  564. this.$message.error(data.msg)
  565. }
  566. })
  567. }).catch(() => { })
  568. },
  569. syncHandle(id) {
  570. if (!id) return
  571. this.$confirm(`确定同步仓库?`, '提示', {
  572. confirmButtonText: '确定',
  573. cancelButtonText: '取消',
  574. type: 'warning'
  575. }).then(() => {
  576. this.$http({
  577. url: this.$http.adornUrl(`/biz-service/product/synchronization`),
  578. method: 'POST',
  579. data: { id: id }
  580. }).then(({ data }) => {
  581. if (data && data.code === '200') {
  582. this.$message({
  583. message: '操作成功',
  584. type: 'success',
  585. duration: 1500,
  586. onClose: () => {
  587. this.getDataList()
  588. }
  589. })
  590. } else {
  591. this.$message.error(data.msg)
  592. }
  593. })
  594. }).catch(() => { })
  595. },
  596. importFromExcel() {
  597. this.importVisible = true
  598. },
  599. handleUpload(file) {
  600. if (file == null) {
  601. this.$message.error('请上传清单文件')
  602. return
  603. }
  604. this.importLoading = true
  605. const formData = new FormData()
  606. formData.append('importFile', file.file)
  607. this.$http({
  608. url: this.$http.adornUrl(`/biz-service/product/importExcel`),
  609. method: 'POST',
  610. data: formData,
  611. timeout: 0
  612. }).then(({ data }) => {
  613. this.importLoading = false
  614. if (data && data.code === '200') {
  615. this.$message({
  616. message: '导入成功',
  617. type: 'success',
  618. duration: 1500,
  619. onClose: () => {
  620. this.importVisible = false
  621. }
  622. })
  623. } else {
  624. this.$message.error(data.msg)
  625. }
  626. })
  627. },
  628. // 上传
  629. submitUpload() {
  630. this.$refs.upload.submit()
  631. },
  632. // 移除
  633. handleRemove(file, fileList) {
  634. this.$emit('input', fileList)
  635. },
  636. templateDownload() {
  637. location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
  638. },
  639. loadingData(row, treeNode, resolve) {
  640. if (!this.treeMap.has(row.productId)) {
  641. this.treeMap.set(row.productId, { row, treeNode, resolve })
  642. }
  643. // console.log(row, treeNode, resolve)
  644. getChildren(row.productId).then(({ data }) => {
  645. if (data && data.code === '200') {
  646. data.data.forEach(item => {
  647. if (item.attachList2 && item.attachList2.length > 0) {
  648. item.simplePic = downloadUrl + item.attachList2[0].url
  649. } else {
  650. item.simplePic = ''
  651. }
  652. })
  653. row.children = data.data
  654. resolve(data.data)
  655. } else {
  656. this.$message.error(data.msg)
  657. }
  658. })
  659. },
  660. handleExpandChange(row, expanded) {
  661. // console.log(row, expanded)
  662. if (expanded) {
  663. this.expandedRowKeys.push(row.productId)
  664. } else {
  665. const index = this.expandedRowKeys.indexOf(row.productId)
  666. if (index !== -1) {
  667. this.expandedRowKeys.splice(index, 1)
  668. }
  669. }
  670. },
  671. openDetail(row, column, event) {
  672. const index = this.expandedRowKeys.indexOf(row.productId)
  673. if (index !== -1) {
  674. this.expandedRowKeys.splice(index, 1)
  675. } else {
  676. this.expandedRowKeys.push(row.productId)
  677. }
  678. if (event.currentTarget.querySelector('.el-table__expand-icon')) {
  679. event.currentTarget.querySelector('.el-table__expand-icon').click()
  680. }
  681. }
  682. }
  683. }
  684. </script>
  685. <style scoped lang="scss">
  686. /deep/ .product-management .el-table__row--level-1>td {
  687. background-color: #5e616444;
  688. }
  689. </style>