statistics0.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <!-- -->
  2. <template>
  3. <div class="statistics0">
  4. <TabList />
  5. <div class="right">
  6. <div class="top">
  7. <el-breadcrumb separator="/">
  8. <el-breadcrumb-item to="">首页</el-breadcrumb-item>
  9. <el-breadcrumb-item to="">库房管理</el-breadcrumb-item>
  10. <el-breadcrumb-item id="mytitle">库房设置</el-breadcrumb-item>
  11. </el-breadcrumb>
  12. </div>
  13. <div class="conten">
  14. <div class="conten_left">
  15. <div class="btn">
  16. <el-button type="primary" @click="addOne" v-show="userLogo.add">新建库区</el-button>
  17. <el-button type="danger" @click="delOne" v-show="userLogo.del">删除</el-button>
  18. </div>
  19. <div class="box" v-for="(item, index) in allList" :key="item.id">
  20. <div class="title" :style="arrowsShow === index?'background-color: #f2f2f2;':''">
  21. <i
  22. :class="
  23. arrowsShow === index
  24. ? 'el-icon-arrow-up'
  25. : 'el-icon-arrow-down'
  26. "
  27. @click="arrowsShowClick(index)"
  28. ></i>
  29. <span @click="arrowsShowClick(index)">{{ item.name }}</span>
  30. <i class="el-icon-plus tiny" @click="addTow(item.id)" v-show="userLogo.add"></i>
  31. <i class="el-icon-edit tiny" @click="editOne(item)" v-show="userLogo.edit"></i>
  32. </div>
  33. <ul class="area" v-show="arrowsShow === index">
  34. <li
  35. :class="{ active: entrepotShow === ind }"
  36. @click="entrepotShowClick(ind, val)"
  37. v-for="(val, ind) in item.children"
  38. :key="val.id"
  39. >
  40. {{ val.name }} 编号:{{ val.num }}
  41. </li>
  42. </ul>
  43. </div>
  44. </div>
  45. <div class="conten_right">
  46. <div class="title" v-show="towList.name">
  47. <b>{{ towList.name }}</b>
  48. <span>仓库编号:{{ towList.num }}</span>
  49. <i class="el-icon-plus" @click="addThree" v-show="userLogo.add"></i>
  50. <i class="el-icon-edit" @click="editTow" v-show="userLogo.edit"></i>
  51. <i class="el-icon-delete" @click="delTow" v-show="userLogo.del"></i>
  52. </div>
  53. <!-- 表格 -->
  54. <div class="table" v-if="towList.name">
  55. <el-table
  56. :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
  57. :data="tableData"
  58. border
  59. style="width: 100%"
  60. >
  61. <el-table-column
  62. prop="num"
  63. label="货架编号"
  64. width="200"
  65. ></el-table-column>
  66. <el-table-column
  67. prop="name"
  68. label="货架名称"
  69. width="200"
  70. ></el-table-column>
  71. <el-table-column
  72. prop="description"
  73. label="备注"
  74. ></el-table-column>
  75. <el-table-column label="操作" width="150">
  76. <template #default='{row}'>
  77. <i class="el-icon-edit" @click="editThree(row)" v-show="userLogo.edit"></i>
  78. <i class="el-icon-delete" @click="delThree(row.id)" v-show="userLogo.del"></i>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. </div>
  83. <div v-else class="mydis">请先新建仓库</div>
  84. <!-- 分页器 -->
  85. <div class="paging" v-if="0">
  86. <el-pagination
  87. background
  88. layout="prev, pager, next,sizes,jumper"
  89. :total="30"
  90. >
  91. </el-pagination>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <!-- 新建库区弹出层--第一层 -->
  97. <el-dialog title="库区名称" :visible="popupOne" @close="popupOneX()">
  98. <el-input v-model="popupOneName" placeholder="请输入库区名称"></el-input>
  99. <div slot="footer" class="dialog-footer">
  100. <el-button @click="popupOneX">取 消</el-button>
  101. <el-button type="primary" @click="popupOneOK">确 定</el-button>
  102. </div>
  103. </el-dialog>
  104. <!-- 新建库区弹出层--第二层 -->
  105. <el-dialog title="库房信息" :visible="popupTow" @close="popupTowX()">
  106. 仓库编号:<el-input v-model="popupTowNum" placeholder="请输入仓库编号" style="width:91%;margin-bottom:20px"></el-input>
  107. 仓库名称:<el-input v-model="popupTowName" placeholder="请输入仓库名称" style="width:91%"></el-input>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button @click="popupTowX">取 消</el-button>
  110. <el-button type="primary" @click="popupTowOK">确 定</el-button>
  111. </div>
  112. </el-dialog>
  113. <!-- 新建库区弹出层--第三层 -->
  114. <el-dialog title="货架信息" :visible="popupThree" @close="popupThreeX()">
  115. 货架编号:<el-input v-model="popupThreeNum" placeholder="请输入货架编号" style="width:91%;margin-bottom:20px"></el-input>
  116. 货架名称:<el-input v-model="popupThreeName" placeholder="请输入货架名称" style="width:91%;margin-bottom:20px"></el-input>
  117. <div class="row">
  118. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注:<el-input type="textarea" :rows="3" v-model="popupThreeTxt" placeholder="请输入备注说明" style="width:91%"></el-input>
  119. </div>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button @click="popupThreeX">取 消</el-button>
  122. <el-button type="primary" @click="popupThreeOK">确 定</el-button>
  123. </div>
  124. </el-dialog>
  125. </div>
  126. </template>
  127. <script>
  128. import { getTreeList, addEntrepot, remove } from '../../apis/statistics0'
  129. import TabList from '@/components/tabLeft3.vue'
  130. export default {
  131. name: 'system0',
  132. // import引入的组件需要注入到对象中才能使用
  133. components: { TabList },
  134. data () {
  135. // 这里存放数据
  136. return {
  137. userLogo: {
  138. add: true, // 新增
  139. edit: true, // 编辑
  140. del: true// 删除
  141. },
  142. myId: null,
  143. // 第一层:箭头的显示隐藏
  144. arrowsShow: 0,
  145. popupOneName: '',
  146. popupOne: false,
  147. // 第二层:库区的显示和隐藏
  148. // 添加第二层的时候临时储存的第一层父亲的id
  149. popupTowId: null,
  150. entrepotShow: 0,
  151. popupTow: false,
  152. popupTowName: '',
  153. popupTowNum: '',
  154. // 第三层:
  155. popupThree: false,
  156. popupThreeNum: '',
  157. popupThreeName: '',
  158. popupThreeTxt: '',
  159. // 第二层数据
  160. towList: {},
  161. // 总数据
  162. allList: [],
  163. // 表格数据
  164. tableData: []
  165. }
  166. },
  167. // 监听属性 类似于data概念
  168. computed: {},
  169. // 监控data中的数据变化
  170. watch: {
  171. arrowsShow (val) {
  172. // console.log(999, val)
  173. if (val !== null) {
  174. if (this.allList[val].children) {
  175. this.tableData = this.allList[val].children[0].children
  176. this.$nextTick(() => {
  177. setTimeout(() => {
  178. this.towList = this.allList[val].children[0]
  179. }, 100)
  180. })
  181. } else {
  182. this.tableData = []
  183. this.towList = {}
  184. }
  185. }
  186. },
  187. entrepotShow (val) {
  188. // console.log(666, val)
  189. this.tableData = this.allList[this.arrowsShow].children[val].children
  190. }
  191. },
  192. // 方法集合
  193. methods: {
  194. // 点击新增库区--第一层
  195. editOne (val) {
  196. this.popupOneName = val.name
  197. this.myId = val.id
  198. this.popupOne = true
  199. },
  200. delOne () {
  201. if (!this.arrowsShow) return this.$message.error('未选中库区')
  202. this.$confirm('确定删除吗?', '提示', {
  203. confirmButtonText: '确定',
  204. cancelButtonText: '取消',
  205. type: 'warning'
  206. }).then(() => {
  207. remove(this.allList[this.arrowsShow].id)
  208. this.arrowsShow = null
  209. this.$nextTick(() => {
  210. setTimeout(() => {
  211. this.getTreeList()
  212. }, 100)
  213. })
  214. this.$message({
  215. type: 'success',
  216. message: '删除成功!'
  217. })
  218. }).catch(() => {
  219. this.$message({
  220. type: 'info',
  221. message: '已取消删除'
  222. })
  223. })
  224. },
  225. addOne () {
  226. this.myId = null
  227. this.popupOne = true
  228. },
  229. popupOneX () {
  230. this.popupOne = false
  231. this.popupOneName = ''
  232. },
  233. async popupOneOK () {
  234. if (this.popupOneName.trim() === '') return this.$message.error('库区名称不能为空')
  235. if (this.popupOneName.length > 8) return this.$message.error('库区名称不能超过15个字符')
  236. await addEntrepot({
  237. level: 1,
  238. name: this.popupOneName,
  239. parentId: null,
  240. id: this.myId
  241. })
  242. this.popupOne = false
  243. this.popupOneName = ''
  244. this.getTreeList()
  245. this.myId = null
  246. this.$message.success('库区操作成功')
  247. },
  248. // 点击第二层+号
  249. delTow () {
  250. this.$confirm('确定删除吗?', '提示', {
  251. confirmButtonText: '确定',
  252. cancelButtonText: '取消',
  253. type: 'warning'
  254. }).then(() => {
  255. // console.log(666, this.allList[this.arrowsShow].children[this.entrepotShow].id)
  256. remove(this.allList[this.arrowsShow].children[this.entrepotShow].id)
  257. this.entrepotShow = 0
  258. this.$nextTick(() => {
  259. setTimeout(() => {
  260. this.getTreeList()
  261. }, 100)
  262. })
  263. this.$message({
  264. type: 'success',
  265. message: '删除成功!'
  266. })
  267. }).catch(() => {
  268. this.$message({
  269. type: 'info',
  270. message: '已取消删除'
  271. })
  272. })
  273. },
  274. editTow () {
  275. // console.log(666, this.towList.name)
  276. this.popupTowName = this.towList.name
  277. this.popupTowNum = this.towList.num
  278. this.myId = this.towList.id
  279. this.popupTow = true
  280. },
  281. addTow (id) {
  282. this.myId = null
  283. this.popupTowId = id
  284. this.popupTow = true
  285. },
  286. popupTowX () {
  287. this.popupTow = false
  288. this.popupTowName = ''
  289. this.popupTowNum = ''
  290. },
  291. async popupTowOK () {
  292. if (this.popupTowNum.trim() === '') return this.$message.error('仓库编号不能为空')
  293. if (this.popupTowNum.length > 8) return this.$message.error('仓库编号不能超过15个字符')
  294. if (this.popupTowName.trim() === '') return this.$message.error('仓库名称不能为空')
  295. if (this.popupTowName.length > 8) return this.$message.error('仓库名称不能超过15个字符')
  296. await addEntrepot({
  297. level: 2,
  298. name: this.popupTowName,
  299. num: this.popupTowNum,
  300. parentId: this.popupTowId,
  301. id: this.myId
  302. })
  303. this.popupTow = false
  304. this.popupTowName = ''
  305. this.popupTowNum = ''
  306. this.getTreeList()
  307. this.myId = null
  308. this.$message.success('仓库操作成功')
  309. },
  310. // 点击第三层
  311. delThree (id) {
  312. this.$confirm('确定删除吗?', '提示', {
  313. confirmButtonText: '确定',
  314. cancelButtonText: '取消',
  315. type: 'warning'
  316. }).then(() => {
  317. remove(id)
  318. // 刷新页面
  319. this.$nextTick(() => {
  320. setTimeout(() => {
  321. this.getTreeList()
  322. this.tableData = this.tableData.filter(v => v.id !== id)
  323. }, 100)
  324. })
  325. this.$message({
  326. type: 'success',
  327. message: '删除成功!'
  328. })
  329. }).catch(() => {
  330. this.$message({
  331. type: 'info',
  332. message: '已取消删除'
  333. })
  334. })
  335. },
  336. editThree (val) {
  337. this.popupThreeName = val.name
  338. this.popupThreeNum = val.num
  339. this.popupThreeTxt = val.description
  340. this.myId = val.id
  341. this.popupThree = true
  342. },
  343. addThree () {
  344. this.myId = null
  345. this.popupThree = true
  346. },
  347. popupThreeX () {
  348. this.popupThree = false
  349. this.popupThreeName = ''
  350. this.popupThreeNum = ''
  351. this.popupThreeTxt = ''
  352. },
  353. async popupThreeOK () {
  354. // console.log(this.towList.id)
  355. if (this.popupThreeNum.trim() === '') return this.$message.error('货架编号不能为空')
  356. if (this.popupThreeName.trim() === '') return this.$message.error('货架名称不能为空')
  357. await addEntrepot({
  358. level: 3,
  359. name: this.popupThreeName,
  360. num: this.popupThreeNum,
  361. parentId: this.towList.id,
  362. description: this.popupThreeTxt,
  363. id: this.myId
  364. })
  365. this.popupThree = false
  366. this.popupThreeName = ''
  367. this.popupThreeNum = ''
  368. this.popupThreeTxt = ''
  369. this.getTreeList()
  370. this.myId = null
  371. this.$message.success('货架操作成功')
  372. // 刷新页面
  373. this.$nextTick(() => {
  374. setTimeout(() => {
  375. this.tableData = this.allList[this.arrowsShow].children[this.entrepotShow].children
  376. }, 100)
  377. })
  378. },
  379. // 点击箭头
  380. arrowsShowClick (index) {
  381. if (this.arrowsShow === index) this.arrowsShow = null
  382. else {
  383. this.arrowsShow = index
  384. this.entrepotShow = 0
  385. }
  386. },
  387. // 点击第二层
  388. entrepotShowClick (ind, val) {
  389. this.entrepotShow = ind
  390. this.towList = val
  391. // console.log(666, val)
  392. },
  393. // 封装获取库房列表方法
  394. async getTreeList () {
  395. const res = await getTreeList()
  396. this.allList = res.data
  397. // console.log(9999, res)
  398. }
  399. },
  400. // 生命周期 - 创建完成(可以访问当前this实例)
  401. created () {},
  402. // 生命周期 - 挂载完成(可以访问DOM元素)
  403. mounted () {
  404. // 调用获取库房列表
  405. this.getTreeList()
  406. this.$nextTick(() => {
  407. setTimeout(() => {
  408. this.towList = this.allList[0].children[0]
  409. this.tableData = this.towList.children
  410. }, 100)
  411. })
  412. // 获取用户角色权限标识
  413. let temp = localStorage.getItem('daliCK')
  414. temp = JSON.parse(temp)
  415. if (temp) {
  416. const temp2 = temp.role[0]
  417. if (temp2 === 'sys_edit') {
  418. this.userLogo.del = false
  419. this.userLogo.add = false
  420. this.userLogo.edit = false
  421. } // 保管部成员
  422. if (temp2 === 'sys_look') {
  423. this.userLogo.del = false
  424. this.userLogo.add = false
  425. this.userLogo.edit = false
  426. } // 其他部门人员
  427. if (temp2 === 'sys_collect') {
  428. this.userLogo.del = false
  429. this.userLogo.add = false
  430. this.userLogo.edit = false
  431. } // 征集部主任
  432. }
  433. },
  434. beforeCreate () {}, // 生命周期 - 创建之前
  435. beforeMount () {}, // 生命周期 - 挂载之前
  436. beforeUpdate () {}, // 生命周期 - 更新之前
  437. updated () {}, // 生命周期 - 更新之后
  438. beforeDestroy () {}, // 生命周期 - 销毁之前
  439. destroyed () {}, // 生命周期 - 销毁完成
  440. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  441. }
  442. </script>
  443. <style lang='less' scoped>
  444. //@import url(); 引入公共css类
  445. .statistics0 {
  446. .row{
  447. display: flex;
  448. align-items: center;
  449. }
  450. /deep/#mytitle > span {
  451. font-weight: 800;
  452. }
  453. display: flex;
  454. .right {
  455. width: 100%;
  456. display: flex;
  457. flex-direction: column;
  458. .top {
  459. padding-left: 35px;
  460. display: flex;
  461. align-items: center;
  462. box-shadow: 1px 1px 10px 1px;
  463. margin-left: 2px;
  464. height: 40px;
  465. background-color: #fff;
  466. }
  467. }
  468. .conten {
  469. flex: 1;
  470. display: flex;
  471. background-color: #fff;
  472. margin: 20px 20px 40px;
  473. padding: 30px 60px 0;
  474. .conten_left {
  475. width: 380px;
  476. height: 650px;
  477. border: 1px solid #ccc;
  478. margin-right: 30px;
  479. .btn {
  480. display: flex;
  481. justify-content: center;
  482. align-items: center;
  483. height: 80px;
  484. }
  485. .title {
  486. span {
  487. cursor: pointer;
  488. }
  489. position: relative;
  490. display: flex;
  491. align-items: center;
  492. height: 55px;
  493. // background-color: #f2f2f2;
  494. color: black;
  495. & > i {
  496. cursor: pointer;
  497. font-size: 30px;
  498. }
  499. & > i:nth-of-type(2) {
  500. right: 35px;
  501. }
  502. .tiny {
  503. position: absolute;
  504. right: 0;
  505. top: 50%;
  506. transform: translateY(-50%);
  507. float: right;
  508. margin: 0 10px;
  509. font-size: 24px;
  510. color: #a5acb3;
  511. }
  512. }
  513. .area {
  514. color: black;
  515. li {
  516. cursor: pointer;
  517. // width: 100%;
  518. // height: 33px;
  519. // line-height: 33px;
  520. margin-left: 50px;
  521. }
  522. li:hover {
  523. color: #1890ff;
  524. }
  525. .active {
  526. color: #1890ff;
  527. }
  528. }
  529. }
  530. .conten_right {
  531. .mydis{
  532. position: absolute;
  533. left: 50%;
  534. top: 50%;
  535. transform: translate(-50%,-50%);
  536. color: black;
  537. font-size: 30px;
  538. }
  539. position: relative;
  540. .table {
  541. /deep/.el-table__body-wrapper{
  542. max-height: 524px;
  543. max-width: 1150px !important;
  544. overflow-y: auto;
  545. }
  546. i {
  547. cursor: pointer;
  548. font-size: 24px;
  549. color: black;
  550. margin-left: 15px;
  551. }
  552. }
  553. .paging {
  554. position: absolute;
  555. left: 50%;
  556. transform: translateX(-50%);
  557. bottom: 20px;
  558. }
  559. flex: 1;
  560. height: 650px;
  561. border: 1px solid #ccc;
  562. .title {
  563. height: 75px;
  564. color: black;
  565. display: flex;
  566. align-items: center;
  567. & > b {
  568. font-size: 24px;
  569. margin: 0 20px;
  570. }
  571. & > span {
  572. margin-right: 20px;
  573. }
  574. & > i {
  575. cursor: pointer;
  576. font-size: 24px;
  577. margin: 0 10px;
  578. }
  579. }
  580. }
  581. }
  582. }
  583. </style>