index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <div v-loading="loadingStatus" element-loading-text="获取数据中,请稍后" element-loading-background="rgba(0, 0, 0, 0.2)">
  3. <el-row style="padding-top: 0">
  4. <el-col :span="4">
  5. <el-card style="height: calc(100vh - 110px); margin-right: 10px">
  6. <el-input v-model="inputCategory" placeholder="请输入产品分类" size="small" clearable></el-input>
  7. <div style="margin-top: 15px; height: calc(100vh - 170px)" class="scroll">
  8. <el-tree
  9. ref="treeCategory"
  10. :data="categoryTreeData"
  11. :props="defaultProps"
  12. node-key="id"
  13. default-expand-all
  14. :expand-on-click-node="false"
  15. :filter-node-method="treeCategory"
  16. @node-click="handleNodeClick"
  17. ></el-tree>
  18. </div>
  19. </el-card>
  20. </el-col>
  21. <el-col :span="20">
  22. <el-card style="height: calc(100vh - 110px)" class="scroll">
  23. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  24. <el-form-item label="群组品名" prop="nameChinese">
  25. <el-input v-model="queryParams.nameChinese" placeholder="请输入群组品名" clearable size="small" @keyup.enter.native="handleQuery" />
  26. </el-form-item>
  27. <el-form-item label="BOM品号" prop="bomColorSpecCode">
  28. <el-input v-model="queryParams.bomColorSpecCode" placeholder="请输入BOM品号" clearable size="small" @keyup.enter.native="handleQuery" />
  29. </el-form-item>
  30. <el-form-item label="BOM品名" prop="bomColorName">
  31. <el-input v-model="queryParams.bomColorName" placeholder="请输入BOM品名" clearable size="small" @keyup.enter.native="handleQuery" />
  32. </el-form-item>
  33. <el-form-item label="种类" prop="generalCategory">
  34. <el-select v-model="queryParams.generalCategory" placeholder="请选择种类" size="small" @change="handleQuery">
  35. <el-option v-for="item in generalCategory" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="色层" prop="chromatogram">
  39. <el-select v-model="queryParams.chromatogram" placeholder="请选择色层" size="small" @change="handleQuery">
  40. <el-option v-for="item in chromatogram" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="压纹工艺" prop="formula">
  44. <el-select v-model="queryParams.formula" placeholder="请选择压纹工艺" size="small" @change="handleQuery">
  45. <el-option v-for="item in formula" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="正面纹路" prop="frontalGrain">
  49. <el-select v-model="queryParams.frontalGrain" placeholder="请选择正面纹路" size="small" @change="handleQuery">
  50. <el-option v-for="item in frontalGrain" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="背面纹路" prop="reverseGrain">
  54. <el-select v-model="queryParams.reverseGrain" placeholder="请选择背面纹路" size="small" @change="handleQuery">
  55. <el-option v-for="item in reverseGrain" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="颜色" prop="color">
  59. <el-input v-model="queryParams.color" placeholder="请输入颜色" clearable size="small" @keyup.enter.native="handleQuery" />
  60. </el-form-item>
  61. <el-form-item>
  62. <el-button size="mini" @click="handleQuery" class="searchBtn">搜索</el-button>
  63. <el-button size="mini" @click="resetQuery">重置</el-button>
  64. </el-form-item>
  65. </el-form>
  66. <el-row :gutter="10" style="margin-bottom: 10px" v-if="!selectStatus">
  67. <el-button type="primary" size="mini" @click="handleAdd">添加BOM</el-button>
  68. </el-row>
  69. <div style="width: 100%; position: relative">
  70. <div style="position: absolute; right: 0; top: -34px; width: 120px; text-align: center">
  71. <el-button type="primary" size="mini" @click="openOperationLog = true" v-db-click>操作日志</el-button>
  72. </div>
  73. <el-table
  74. v-loading="loadingTable"
  75. :data="productList"
  76. size="small"
  77. :row-style="{ height: '35px' }"
  78. :cell-style="{ padding: '0' }"
  79. header-row-class-name="tableHeader"
  80. >
  81. <el-table-column label="" type="expand" width="50">
  82. <template slot-scope="scope">
  83. <div>
  84. <el-table
  85. :data="scope.row.bomColors"
  86. size="small"
  87. :row-style="{ height: '35px' }"
  88. :cell-style="{ padding: '0' }"
  89. header-row-class-name="tableHeader"
  90. :show-header="false"
  91. >
  92. <el-table-column width="150" align="center" />
  93. <el-table-column label="设计图" width="100">
  94. <template slot-scope="scope">
  95. <div v-if="scope.row.magPath">
  96. <img
  97. style="width: 32px; height: 32px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer; margin-bottom: 8px"
  98. :src="pathPrefix + scope.row.magPath"
  99. @click="openFile(pathPrefix + scope.row.magPath)"
  100. />
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="品号" prop="specCode" width="200" />
  105. <el-table-column label="品名" prop="nameChinese" />
  106. <el-table-column label="单品尺寸(L*W*H)" prop="specCode" width="240">
  107. <template slot-scope="scope">
  108. <span>{{ `${scope.row.productLong} * ${scope.row.productWide} * ${scope.row.productHigh}` }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="操作" prop="weight" width="80" v-if="selectStatus">
  112. <template slot-scope="sonScope">
  113. <div>
  114. <el-button type="text" @click="selectBOM(scope.row, sonScope.$index)" v-db-click>选择</el-button>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. </div>
  120. </template>
  121. </el-table-column>
  122. <!-- <el-table-column label="图片" width="100">
  123. <template width="90" slot-scope="scope">
  124. <img
  125. v-if="scope.row.pic"
  126. style="width: 50px; height: 50px; object-fit: contain; vertical-align: middle; border: none; padding: 8px 0; cursor: pointer"
  127. :src="pathPrefix + scope.row.pic"
  128. @click="openFile(pathPrefix + scope.row.pic)"
  129. />
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="群组品号" prop="code" width="160" /> -->
  133. <el-table-column label="群组品名" min-width="200">
  134. <template slot-scope="scope">
  135. <span style="color: #409eff; cursor: pointer" @click="clickProductName(scope.row)">{{ scope.row.nameChinese }}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="项目小类" width="120" :formatter="projectTypeFormat" />
  139. <el-table-column label="种类" width="120" :formatter="generalCategoryFormat" />
  140. <el-table-column label="色层" width="120" :formatter="chromatogramFormat" />
  141. <el-table-column label="压纹工艺" width="120" :formatter="formulaFormat" />
  142. <el-table-column label="正面纹路" width="120" :formatter="frontalGrainFormat" />
  143. <el-table-column label="背面纹路" width="120" :formatter="reverseGrainFormat" />
  144. <!-- <el-table-column label="报价规则名称" prop="newSalesQuotationName" width="140" /> -->
  145. <el-table-column label="操作" align="center" width="120" fixed="right">
  146. <template slot-scope="scope">
  147. <el-button type="text" @click="handleUpdate(scope.row)" v-db-click>修改</el-button>
  148. <el-button type="text" @click="handleDelete(scope.row)" v-db-click>删除</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  153. </div>
  154. </el-card>
  155. </el-col>
  156. </el-row>
  157. <el-dialog v-if="openBOM" :visible.sync="openBOM" width="90%" append-to-body :close-on-click-modal="false">
  158. <BOM :rowData="rowData" @clickCancel="clickCancel"></BOM>
  159. </el-dialog>
  160. <el-dialog v-if="openBOMDetails" :visible.sync="openBOMDetails" width="90%" append-to-body :close-on-click-modal="false">
  161. <BOMDetails :rowData="rowData" @clickCancel="clickCancelDetails"></BOMDetails>
  162. </el-dialog>
  163. <el-dialog title="操作日志" v-if="openOperationLog" :visible.sync="openOperationLog" width="50%" append-to-body>
  164. <OperationLog :operationLogKey="operationLogKey"></OperationLog>
  165. <div style="text-align: center; margin-top: 20px">
  166. <el-button @click="openOperationLog = false" v-db-click>关 闭</el-button>
  167. </div>
  168. </el-dialog>
  169. </div>
  170. </template>
  171. <script>
  172. import * as API from '@/api/shengde/group/BOM/bom'
  173. import { categoryList } from '@/api/shengde/group/BOM/category'
  174. import { mapGetters } from 'vuex'
  175. import BOM from '@/views/AddOrModifiedProduct/BOM'
  176. import BOMDetails from '@/views/shengde/group/BOM/library/details'
  177. import OperationLog from '@/components/shengde/operationLog/index'
  178. export default {
  179. name: 'BOMLibrary',
  180. components: { BOM, BOMDetails, OperationLog },
  181. props: {
  182. selectStatus: {
  183. type: Boolean,
  184. default: false,
  185. },
  186. },
  187. data() {
  188. return {
  189. value: '',
  190. pathPrefix: process.env.VUE_APP_IMG_URL,
  191. inputCategory: '',
  192. categoryTreeData: [],
  193. defaultProps: {
  194. children: 'children',
  195. label: 'text',
  196. },
  197. // 显示搜索条件
  198. showSearch: true,
  199. // 总条数
  200. total: 0,
  201. // 产品信息表格数据
  202. productList: [],
  203. loadingTable: false,
  204. // 是否显示弹出层
  205. openBOM: false,
  206. openBOMDetails: false,
  207. // 查询参数
  208. queryParams: {
  209. pageNum: 1,
  210. pageSize: 10,
  211. categoryId: '',
  212. nameChinese: '',
  213. categoryType: '',
  214. bomColorName: '',
  215. bomColorSpecCode: '',
  216. generalCategory: '',
  217. chromatogram: '',
  218. formula: '',
  219. reverseGrain: '',
  220. frontalGrain: '',
  221. color: '',
  222. },
  223. // 表单参数
  224. form: {
  225. attachments: [],
  226. materials: [],
  227. },
  228. fileData: [],
  229. loadingStatus: false,
  230. rowData: {},
  231. productCategoryType: [],
  232. generalCategory: [],
  233. chromatogram: [],
  234. formula: [],
  235. reverseGrain: [],
  236. frontalGrain: [],
  237. projectType: [],
  238. openOperationLog: false,
  239. operationLogKey: 30,
  240. }
  241. },
  242. created() {
  243. this.productCategoryType = this.dictData
  244. .filter((item) => item.code === 'bom_category_type')[0]
  245. .children.map((item, index) => {
  246. return {
  247. ...item,
  248. children: [],
  249. text: item.dictValue,
  250. attrs: {
  251. sort: index,
  252. },
  253. id: item.dictKey,
  254. }
  255. })
  256. this.generalCategory = this.dictData.filter((item) => item.code === 'generalCategory')[0].children
  257. this.chromatogram = this.dictData.filter((item) => item.code === 'bom_chromatogram')[0].children
  258. this.formula = this.dictData.filter((item) => item.code === 'formula')[0].children
  259. this.reverseGrain = this.dictData.filter((item) => item.code === 'reverse_grain')[0].children
  260. this.frontalGrain = this.dictData.filter((item) => item.code === 'frontal_grain')[0].children
  261. this.projectType = this.dictData.filter((item) => item.code === 'project_type')[0].children
  262. this.getCategory()
  263. },
  264. mounted() {
  265. this.getList()
  266. },
  267. watch: {
  268. inputCategory(val) {
  269. this.$refs.treeCategory.filter(val)
  270. },
  271. },
  272. computed: mapGetters(['menuAll', 'token', 'dictData', 'userInfo']),
  273. methods: {
  274. changeValue(val) {
  275. this.form.categoryId = val.toString()
  276. },
  277. treeCategory(value, data) {
  278. if (!value) return true
  279. return data.text.indexOf(value) !== -1
  280. },
  281. handleNodeClick(data) {
  282. this.queryParams.pageNum = 1
  283. if (data.dictKey) {
  284. this.queryParams.categoryType = data.dictKey
  285. this.queryParams.categoryId = ''
  286. } else {
  287. this.queryParams.categoryType = ''
  288. this.queryParams.categoryId = data.id
  289. }
  290. this.getList()
  291. },
  292. getCategory() {
  293. categoryList({}).then((res) => {
  294. this.categoryTreeData = JSON.parse(JSON.stringify(this.productCategoryType))
  295. let data = this.handleTree(res.data.data, 'id', 'pId')
  296. if (data && data.length > 0) {
  297. for (let i = 0; i < this.categoryTreeData.length; i++) {
  298. for (let j = 0; j < data.length; j++) {
  299. if (this.categoryTreeData[i].dictKey === data[j].attrs.categoryType) {
  300. this.categoryTreeData[i].children.push(data[j])
  301. }
  302. }
  303. }
  304. }
  305. })
  306. },
  307. /** 查询产品信息列表 */
  308. getList() {
  309. this.loadingTable = true
  310. API.list(this.queryParams).then(
  311. (res) => {
  312. if (res.data.data.records && res.data.data.records.length > 0) {
  313. res.data.data.records = res.data.data.records.map((item) => {
  314. if (item.bomColors && item.bomColors.length > 0) {
  315. item.bomColors = item.bomColors.map((itemBomColors) => {
  316. itemBomColors.nameChinese = itemBomColors.nameChinese.replace(item.nameChinese + ' : ', '')
  317. itemBomColors.nameChinese = itemBomColors.nameChinese.replace(item.nameChinese + ':', '')
  318. return {
  319. ...itemBomColors,
  320. }
  321. })
  322. }
  323. return {
  324. ...item,
  325. }
  326. })
  327. }
  328. this.total = res.data.data.total
  329. this.productList = res.data.data.records
  330. this.loadingTable = false
  331. },
  332. (err) => {
  333. console.log('list: ' + err)
  334. this.loadingTable = false
  335. }
  336. )
  337. },
  338. /** 搜索按钮操作 */
  339. handleQuery() {
  340. this.queryParams.pageNum = 1
  341. this.getList()
  342. },
  343. /** 重置按钮操作 */
  344. resetQuery() {
  345. this.resetForm('queryForm')
  346. this.queryParams.categoryId = ''
  347. this.queryParams.categoryType = ''
  348. this.$refs.treeCategory.setCurrentKey(null)
  349. this.handleQuery()
  350. },
  351. /** 新增按钮操作 */
  352. handleAdd() {
  353. this.rowData = {}
  354. this.openBOM = true
  355. },
  356. /** 修改按钮操作 */
  357. handleUpdate(row) {
  358. this.rowData = row
  359. this.openBOM = true
  360. },
  361. /** 删除按钮操作 */
  362. handleDelete(row) {
  363. this.$confirm('是否确认删除群组名称为"' + row.nameChinese + '"的数据项?', '警告', {
  364. confirmButtonText: '确定',
  365. cancelButtonText: '取消',
  366. type: 'warning',
  367. })
  368. .then(function () {
  369. return API.del({ id: row.id })
  370. })
  371. .then(() => {
  372. this.$message({
  373. type: 'success',
  374. message: '删除成功',
  375. })
  376. this.queryParams.pageNum = 1
  377. this.getList()
  378. })
  379. },
  380. clickProductName(row) {
  381. this.rowData = row
  382. this.openBOMDetails = true
  383. },
  384. clickCancel(status) {
  385. this.openBOM = false
  386. if (status) {
  387. this.getList()
  388. }
  389. },
  390. clickCancelDetails() {
  391. this.openBOMDetails = false
  392. },
  393. openFile(path) {
  394. window.open(path)
  395. },
  396. handleProLibrary() {
  397. this.openProLibrary = true
  398. },
  399. selectBOM(row, index) {
  400. this.$emit('selectBOM', row, index)
  401. },
  402. beforeUpload(file) {
  403. this.errMsg = ''
  404. const isLt50M = file.size / 1024 / 1024 < 50
  405. if (!isLt50M) {
  406. this.$message.error('上传文件大小不能超过50MB!')
  407. }
  408. return isLt50M
  409. },
  410. excelProgress() {
  411. this.openProLibrary = true
  412. },
  413. excelSuccess() {
  414. this.msgSuccess('文件导入成功')
  415. this.openProLibrary = false
  416. this.getList()
  417. },
  418. excelError(err) {
  419. var res = JSON.parse(err.message)
  420. this.errMsg = '导入失败: ' + res.msg
  421. this.openProLibrary = false
  422. },
  423. generalCategoryFormat(row) {
  424. return this.selectConstantsLabel(this.generalCategory, row.generalCategory)
  425. },
  426. chromatogramFormat(row) {
  427. return this.selectConstantsLabel(this.chromatogram, row.chromatogram)
  428. },
  429. formulaFormat(row) {
  430. return this.selectConstantsLabel(this.formula, row.formula)
  431. },
  432. frontalGrainFormat(row) {
  433. return this.selectConstantsLabel(this.frontalGrain, row.frontalGrain)
  434. },
  435. reverseGrainFormat(row) {
  436. return this.selectConstantsLabel(this.reverseGrain, row.reverseGrain)
  437. },
  438. projectTypeFormat(row) {
  439. return this.selectConstantsLabel(this.projectType, row.projectType)
  440. },
  441. },
  442. }
  443. </script>
  444. <style lang="scss" scoped>
  445. /deep/ .el-tree-node__label {
  446. font-size: 12px !important;
  447. }
  448. * {
  449. font-size: 12px;
  450. }
  451. .el-tree {
  452. display: inline-block;
  453. min-width: 100%;
  454. }
  455. ::v-deep {
  456. .el-input__inner {
  457. border-radius: 1px;
  458. }
  459. .el-button--mini {
  460. border-radius: 1px;
  461. }
  462. .tableHeader th {
  463. background-color: #edf0f5;
  464. height: 35px;
  465. padding: 0;
  466. }
  467. .el-dialog__footer {
  468. text-align: center;
  469. padding-bottom: 50px;
  470. .el-button {
  471. border-radius: 1px;
  472. }
  473. }
  474. .el-card__body {
  475. padding: 15px;
  476. }
  477. .el-table__cell {
  478. vertical-align: middle !important;
  479. }
  480. .el-input-number {
  481. .el-input__inner {
  482. text-align: left !important;
  483. }
  484. }
  485. }
  486. .box-card {
  487. height: calc(100vh - 50px - 50px - 10px);
  488. // overflow-y: auto;
  489. }
  490. .searchBtn {
  491. background: #20b2aa;
  492. color: #fff;
  493. border: 1px solid #20b2aa;
  494. }
  495. // 详情页需要加这个
  496. /deep/ .el-dialog {
  497. margin: 0 auto;
  498. margin-top: 10px !important;
  499. }
  500. .scroll {
  501. overflow: hidden overlay !important;
  502. &::-webkit-scrollbar {
  503. width: 0px;
  504. }
  505. &:hover {
  506. &::-webkit-scrollbar {
  507. width: 7px;
  508. }
  509. }
  510. }
  511. </style>