product-management.vue 26 KB

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