product-management.vue 25 KB

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