Index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!-- 左结构-Tree结构 -->
  5. <el-col :span="5">
  6. <el-input
  7. :placeholder='$t("lineSide.tips.treeTips")'
  8. v-model="filterText">
  9. </el-input>
  10. <el-tree
  11. :data="treeData"
  12. show-checkbox
  13. :highlight-current="true"
  14. :default-expand-all="true"
  15. :check-strictly="true"
  16. :check-on-click-node="true"
  17. node-key="id"
  18. :props="defaultProps"
  19. ref="tree"
  20. :filter-node-method="filterNode"
  21. @check="treeCheck"
  22. >
  23. </el-tree>
  24. </el-col>
  25. <!-- 右结构-主要内容 -->
  26. <el-col :span="19">
  27. <!-- 搜索模块 -->
  28. <div class="filter-container">
  29. <span>
  30. <span>{{$t("lineSide.searchForm.productName")}}:</span>
  31. <el-input v-model="queryParams.model.name" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
  32. </span>
  33. <span style="margin-left: 15px;">
  34. <span>{{$t("lineSide.searchForm.wareType")}}:</span>
  35. <el-select v-model="queryParams.model.storgeTypeId" :placeholder='$t("common.pleaseSelect")' size="medium" style="width: 150px;">
  36. <el-option
  37. v-for="item in wareTypeList"
  38. :key="item.id"
  39. :label="item.name"
  40. :value="item.id">
  41. </el-option>
  42. </el-select>
  43. </span>
  44. <span style="margin-left: 15px;">
  45. <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
  46. {{ $t("common.search") }}
  47. </el-button>
  48. <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
  49. {{ $t("common.reset") }}
  50. </el-button>
  51. </span>
  52. </div>
  53. <!-- 功能按钮 -->
  54. <el-row class="filter-container">
  55. <el-col>
  56. <el-button type="primary" icon="el-icon-download" size="medium" v-has-permission="['lineSide:stockin']" @click="add">{{ $t("lineSide.buttons.warehousing") }}</el-button>
  57. <el-button type="success" icon="el-icon-download" size="medium" v-has-permission="['lineSide:batchStockin']" @click="editList">{{ $t("lineSide.buttons.warehousingList") }}</el-button>
  58. <el-button type="success" icon="el-icon-upload2" size="medium" v-has-permission="['lineSide:taskStockin']" @click="editOne">{{ $t("lineSide.buttons.rewuWarehousing") }}</el-button>
  59. <el-button type="success" icon="el-icon-unlock" size="medium" v-has-permission="['lineSide:unlockStorge']" @click="unlockProd">{{ $t("lineSide.buttons.unlock") }}</el-button>
  60. <el-button type="danger" icon="el-icon-lock" size="medium" v-has-permission="['lineSide:lockStorge']" @click="lockingProd">{{ $t("lineSide.buttons.locking") }}</el-button>
  61. </el-col>
  62. </el-row>
  63. <!-- 列表数据 -->
  64. <el-table
  65. :key="tableKey"
  66. ref="table"
  67. v-loading="loading"
  68. :data="tableData.records"
  69. border
  70. fit
  71. row-key="id"
  72. style="width: 100%;"
  73. highlight-current-row
  74. @current-change="handleCurrentChange"
  75. >
  76. <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
  77. <template slot-scope="scope">
  78. <div>
  79. {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
  80. </div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="no" :label='$t("lineSide.table.side.no")' :show-overflow-tooltip="true" width="200px"></el-table-column>
  84. <el-table-column prop="name" :label='$t("lineSide.table.side.name")' :show-overflow-tooltip="true" width="150px"></el-table-column>
  85. <el-table-column prop="storgeTypeDesc" :label='$t("lineSide.table.side.storgeTypeDesc")' :show-overflow-tooltip="true"></el-table-column>
  86. <el-table-column prop="lockStatus" :label='$t("lineSide.table.side.lockStatus")' align="center" width="90px">
  87. <template slot-scope="{ row }">
  88. <el-tag :type="row.lockStatus=='0' ? 'success' : 'danger'">
  89. {{ row.lockStatus=='0' ? $t("common.yes") : $t("common.no") }}
  90. </el-tag>
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="storgeNum" :label='$t("lineSide.table.side.storgeNum")' :show-overflow-tooltip="true"></el-table-column>
  94. </el-table>
  95. <!-- 【分页】组件 -->
  96. <pagination
  97. v-show="tableData.total > 0"
  98. :limit.sync="queryParams.size"
  99. :page.sync="queryParams.current"
  100. :total="Number(tableData.total)"
  101. @pagination="fetch"
  102. />
  103. <!-- 【库位产品】组件 -->
  104. <Warehouse-product
  105. ref="product"
  106. :dialog-visible="dialogPro.isVisible"
  107. :title="dialogPro.title"
  108. @close="editProClose"
  109. @success="editProSuccess"
  110. />
  111. </el-col>
  112. </el-row>
  113. <tenant-edit
  114. ref="edit"
  115. :dialog-visible="dialog.isVisible"
  116. :title="dialog.title"
  117. @close="editClose"
  118. @success="editSuccess"
  119. />
  120. <edit-list
  121. ref="editList"
  122. :dialog-visible="dialogList.isVisible"
  123. :title="dialogList.title"
  124. @close="editListClose"
  125. @success="editSuccess"
  126. />
  127. <tenant-view
  128. ref="view"
  129. :dialog-visible="tenantViewVisible"
  130. @close="viewClose"
  131. />
  132. <el-dialog
  133. v-el-drag-dialog
  134. :close-on-click-modal="false"
  135. :close-on-press-escape="true"
  136. :title='$t("common.preview")'
  137. width="80%"
  138. top="50px"
  139. :visible.sync="preview.isVisible"
  140. >
  141. <el-scrollbar>
  142. <div v-html="preview.context" />
  143. </el-scrollbar>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. // 库位【分页】组件
  149. import Pagination from "@/components/Pagination"
  150. // 【库位产品】组件
  151. import WarehouseProduct from "./components/warehouseProduct/Index"
  152. import TenantEdit from "./components/Edit"
  153. import EditList from "./components/EditList"
  154. import TenantView from "./components/View"
  155. // 【仓库类型管理】-API
  156. import warehouseTypeMgrApi from "@/api/modelingCenter/warehouseTypeMgr"
  157. // 【货架管理】-API
  158. import goodsShelvesMgrApi from "@/api/modelingCenter/goodsShelvesMgr"
  159. // 【边线库管理】-API
  160. import lineSideMgrApi from "@/api/lineSideLibrary/lineSideMgr"
  161. // 【库位管理】-API
  162. import locationMgrApi from "@/api/lineSideLibrary/locationMgr"
  163. import elDragDialog from '@/directive/el-drag-dialog'
  164. import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
  165. import axios from 'axios'
  166. export default {
  167. name: "LineSideMgr",
  168. directives: { elDragDialog },
  169. components: { Pagination, WarehouseProduct, TenantEdit, EditList, TenantView },
  170. props: {
  171. },
  172. data () {
  173. return {
  174. wareTypeList: [], // 库位类型下拉数据
  175. audioStatus: [],
  176. dialogPro: {
  177. isVisible: false,
  178. title: ""
  179. },
  180. dialog: {
  181. isVisible: false,
  182. title: ""
  183. },
  184. dialogList: {
  185. isVisible: false,
  186. title: ""
  187. },
  188. preview: {
  189. isVisible: false,
  190. context: ''
  191. },
  192. tenantViewVisible: false,
  193. tableKey: 0,
  194. queryParams: initQueryParams({}),
  195. selection: [],
  196. loading: false,
  197. tableData: {
  198. total: 0
  199. },
  200. currentRow: null, // 当前选中的行
  201. dicts: {
  202. NATION: {}
  203. },
  204. enums: {
  205. TenantTypeEnum: {},
  206. TenantStatusEnum: {}
  207. },
  208. currNode: {}, //当前选择的树数据
  209. filterText: '',
  210. treeData: [],
  211. defaultProps: {
  212. children: 'children',
  213. label: 'name'
  214. }
  215. }
  216. },
  217. watch: {
  218. filterText(val) {
  219. this.$refs.tree.filter(val);
  220. }
  221. },
  222. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  223. created() {
  224. // 【库位类型】
  225. this.getWareType()
  226. // 加载【字典】
  227. initDicts(['NATION'], this.dicts)
  228. // 加载Tree数据
  229. this.getTreeData()
  230. // 加载列表数据
  231. //this.fetch()
  232. },
  233. computed: {
  234. currentUser () {
  235. return this.$store.state.account.user
  236. },
  237. nationList() {
  238. return convertEnum(this.dicts.NATION)
  239. }
  240. },
  241. mounted () {
  242. },
  243. methods: {
  244. // 【解锁库位】按钮-事件
  245. unlockProd(){
  246. if (!this.currentRow) {
  247. this.$message({
  248. message: this.$t("tips.unSelected"),
  249. type: "warning"
  250. })
  251. return
  252. }
  253. // 调用API-函数
  254. this.locked({id: this.currentRow.id, lockStatus: '1'}, this.$t("tips.unlockSuccess"))
  255. },
  256. // 【锁定库位】按钮-事件
  257. lockingProd(){
  258. if (!this.currentRow) {
  259. this.$message({
  260. message: this.$t("tips.unSelected"),
  261. type: "warning"
  262. })
  263. return
  264. }
  265. // 调用API-函数
  266. this.locked({id: this.currentRow.id, lockStatus: '0'}, this.$t("tips.lockSuccess"))
  267. },
  268. // 调用【解锁和锁定】的API-函数
  269. locked(obj, msg){
  270. locationMgrApi.update(obj).then(res => {
  271. res = res.data
  272. if (res.isSuccess) {
  273. this.isVisible = false
  274. this.$message({
  275. message: msg,
  276. type: 'success'
  277. })
  278. // 重新加载数据
  279. this.search()
  280. }
  281. })
  282. },
  283. // 【库位类型】
  284. getWareType(){
  285. warehouseTypeMgrApi.getList({}).then(res => {
  286. res = res.data
  287. if (res.isSuccess) {
  288. this.wareTypeList = res.data
  289. }
  290. })
  291. },
  292. // table的当前行变化-事件
  293. handleCurrentChange(val){
  294. this.currentRow = val
  295. // 如果值存在
  296. if(val){
  297. // 给下面的列表赋值
  298. this.$refs.product.storgeObj = val
  299. // 加载下面的列表
  300. this.$refs.product.fetch()
  301. }
  302. },
  303. // Tree搜索
  304. filterNode(value, data) {
  305. if (!value) return true;
  306. return data.name.indexOf(value) !== -1;
  307. },
  308. // Tree的CheckBox选中事件
  309. treeCheck(data, checkData){
  310. // console.log("data == ", data)
  311. // console.log("checkData == ", checkData)
  312. // 当前选中的Node
  313. this.currNode = data
  314. // 永远只选择一个CheckBox节点
  315. this.$refs.tree.setCheckedKeys([data.id])
  316. // 加载列表数据
  317. this.fetch()
  318. },
  319. // 【库位产品-关闭】事件
  320. editProClose () {
  321. this.dialogPro.isVisible = false
  322. },
  323. // 【库位产品-确认】事件
  324. editProSuccess(data){
  325. },
  326. viewClose () {
  327. this.tenantViewVisible = false
  328. },
  329. editClose () {
  330. this.dialog.isVisible = false
  331. },
  332. editListClose () {
  333. this.dialogList.isVisible = false
  334. },
  335. editSuccess () {
  336. this.search()
  337. },
  338. onSelectChange (selection) {
  339. this.selection = selection
  340. },
  341. search () {
  342. this.fetch({
  343. ...this.queryParams
  344. })
  345. },
  346. reset () {
  347. this.queryParams = initQueryParams({})
  348. this.$refs.table.clearSort()
  349. this.$refs.table.clearFilter()
  350. this.search()
  351. },
  352. add () {
  353. this.$refs.edit.type = "add"
  354. this.$refs.edit.setTenant(this.currentRow, this.dicts)
  355. this.dialog.title = this.$t("lineSide.common.inWare")
  356. this.dialog.isVisible = true
  357. },
  358. singleDelete (row) {
  359. this.$refs.table.clearSelection()
  360. this.$refs.table.toggleRowSelection(row, true)
  361. this.batchDelete()
  362. },
  363. batchDelete () {
  364. if (!this.selection.length) {
  365. this.$message({
  366. message: this.$t("tips.noDataSelected"),
  367. type: "warning"
  368. })
  369. return
  370. }
  371. const readonlyIndex = this.selection.findIndex(item => item.readonly)
  372. if (readonlyIndex > -1) {
  373. this.$message({
  374. message: this.$t("tips.systemData"),
  375. type: "warning"
  376. })
  377. return
  378. }
  379. this.$confirm(this.$t("lineSide.tips.delTips"), this.$t("common.tips"), {
  380. distinguishCancelAndClose: true,
  381. confirmButtonText: this.$t("common.confirm"),
  382. cancelButtonText: this.$t("common.cancel"),
  383. type: "warning"
  384. }).then(() => {
  385. const ids = []
  386. this.selection.forEach(item => {
  387. ids.push(item.id)
  388. })
  389. this.delete(ids)
  390. }).catch(() => {})
  391. },
  392. clearSelections () {
  393. this.$refs.table.clearSelection()
  394. },
  395. delete (ids) {
  396. lineSideMgrApi.remove({ ids: ids }).then(response => {
  397. const res = response.data
  398. if (res.isSuccess) {
  399. this.$message({
  400. message: this.$t("tips.deleteSuccess"),
  401. type: "success"
  402. })
  403. this.search()
  404. // 清理已经删除的数据
  405. this.$refs.table.clearSelection()
  406. }
  407. })
  408. },
  409. view (row) {
  410. this.$refs.view.setTenant(row)
  411. this.tenantViewVisible = true
  412. },
  413. // 【修改】表头上Btn-事件
  414. editOne() {
  415. if (!this.selection.length) {
  416. this.$message({
  417. message: this.$t("tips.unSelected"),
  418. type: "warning"
  419. })
  420. return
  421. }
  422. if (this.selection.length > 1) {
  423. this.$message({
  424. message: this.$t("tips.mustOne"),
  425. type: "warning"
  426. })
  427. return
  428. }
  429. this.edit(this.selection[0]);
  430. },
  431. edit (row) {
  432. this.$refs.edit.setTenant(row, this.currNode, this.dicts)
  433. this.$refs.edit.type = "edit"
  434. // 【库位】赋值
  435. this.$refs.edit.tenant.name2 = this.currNode.name
  436. this.dialog.title = this.$t("lineSide.buttons.warehousing")
  437. this.dialog.isVisible = true
  438. },
  439. // 【批量入库】
  440. editList(){
  441. /*if (!this.currentRow) {
  442. this.$message({
  443. message: this.$t("tips.unSelected"),
  444. type: "warning"
  445. })
  446. return
  447. }*/
  448. // this.$refs.editList.setTenant(this.currentRow, this.currNode, this.dicts)
  449. this.$refs.editList.type = "add"
  450. this.dialogList.title = this.$t("lineSide.buttons.warehousingList")
  451. this.dialogList.isVisible = true
  452. },
  453. fetch (params = {}) {
  454. this.loading = true
  455. if (this.queryParams.timeRange) {
  456. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  457. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  458. }
  459. this.queryParams.current = params.current ? params.current : this.queryParams.current
  460. this.queryParams.size = params.size ? params.size : this.queryParams.size
  461. // Tree的数据过滤
  462. if(this.currNode){
  463. this.queryParams.model.shelvesId = this.currNode.id
  464. }
  465. locationMgrApi.page(this.queryParams).then(response => {
  466. const res = response.data
  467. if (res.isSuccess) {
  468. // 清除以前的table选中的数据
  469. this.$refs.table.setCurrentRow()
  470. this.tableData = res.data
  471. // 如果有值
  472. if(this.tableData.records.length > 0){
  473. // 默认设置第一条为当前选择的数据
  474. this.$refs.table.setCurrentRow(this.tableData.records[0])
  475. }
  476. }
  477. // eslint-disable-next-line no-return-assign
  478. }).finally(() => this.loading = false)
  479. },
  480. // 加载Tree数据
  481. getTreeData(){
  482. // this.treeData = [{"children":[{"children":[{"children":[],"factoryId":"1314917506283995136","name":"测试001","id":"1315233786719371264","lev":"3","parentId":"1315107643102068736"},{"children":[{"children":[],"factoryId":"1314917506283995136","name":"盒子10010","id":"1315534899016368128","lev":"4","parentId":"1315531557968019456"},{"children":[],"factoryId":"1314917506283995136","name":"盒子边缘","id":"1315534970483113984","lev":"4","parentId":"1315531557968019456"},{"children":[],"factoryId":"1314917506283995136","name":"摸彩盒子","id":"1315537257989406720","lev":"4","parentId":"1315531557968019456"},{"children":[{"children":[],"factoryId":"1314917506283995136","name":"盒子10010","id":"1315577706552754176","lev":"5","parentId":"1315537310871191552"},{"children":[],"factoryId":"1314917506283995136","name":"资源1000号","id":"1315577965492305920","lev":"5","parentId":"1315537310871191552"},{"children":[],"factoryId":"1314917506283995136","name":"资源20000号","id":"1315578031858778112","lev":"5","parentId":"1315537310871191552"},{"children":[],"factoryId":"1314917506283995136","name":"资源888","id":"1315587186984222720","lev":"5","parentId":"1315537310871191552"}],"factoryId":"1314917506283995136","name":"龙须盒子","id":"1315537310871191552","lev":"4","parentId":"1315531557968019456"}],"factoryId":"1314917506283995136","name":"测试盒子2000","id":"1315531557968019456","lev":"3","parentId":"1315107643102068736"}],"factoryId":"1314917506283995136","name":"坦克炮管车间","id":"1315107643102068736","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"坦克履带车间","id":"1315126180059283456","lev":"2","parentId":"1314917506283995136"},{"children":[{"children":[],"factoryId":"1314917506283995136","name":"1323","id":"1315244115171999744","lev":"3","parentId":"1315126690388639744"},{"children":[],"factoryId":"1314917506283995136","name":"范文芳","id":"1315244167751794688","lev":"3","parentId":"1315126690388639744"},{"children":[],"factoryId":"1314917506283995136","name":"任务二千万","id":"1315244222521016320","lev":"3","parentId":"1315126690388639744"},{"children":[],"factoryId":"1314917506283995136","name":"产线10020","id":"1315520376557535232","lev":"3","parentId":"1315126690388639744"}],"factoryId":"1314917506283995136","name":"测试车间","id":"1315126690388639744","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"22222","id":"1315153838193246208","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"3333","id":"1315153862646038528","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"444","id":"1315154005038465024","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"55555","id":"1315154030778908672","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"888888","id":"1315154111124996096","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"44特瑞特","id":"1315218536334884864","lev":"2","parentId":"1314917506283995136"},{"children":[],"factoryId":"1314917506283995136","name":"777","id":"1315294039775379456","lev":"2","parentId":"1314917506283995136"}],"factoryId":"1314917506283995136","name":"测试数据工厂","id":"1314917506283995136","lev":"1","parentId":"0"}]
  483. goodsShelvesMgrApi.getTreeList({}).then(res => {
  484. res = res.data
  485. if(res.isSuccess){
  486. this.treeData = res.data
  487. if(res.data.length > 0){
  488. let obj = res.data[0].children[0]
  489. this.treeCheck(obj, {})
  490. }
  491. }
  492. })
  493. },
  494. cellClick (row, column) {
  495. if (column['columnKey'] === "operation") {
  496. return
  497. }
  498. let flag = false
  499. this.selection.forEach((item) => {
  500. if (item.id === row.id) {
  501. flag = true
  502. this.$refs.table.toggleRowSelection(row)
  503. }
  504. })
  505. if (!flag) {
  506. this.$refs.table.toggleRowSelection(row, true)
  507. }
  508. }
  509. }
  510. }
  511. </script>
  512. <style lang="scss" scoped></style>