statistics2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <!-- -->
  2. <template>
  3. <div class="holding">
  4. <TabList :ind='2'/>
  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="middle">
  15. <ul class="title">
  16. <li :class="{active:stateInd===index}" @click="stateSelect(index)" v-for="(item,index) in stateArr" :key="index">{{item.txt}}({{item.num}})</li>
  17. </ul>
  18. <div class="select">
  19. <span>搜索:</span>
  20. <el-select v-model="myData.type" placeholder="请选择" style="width:108px">
  21. <el-option label="藏品名称" value="name"></el-option>
  22. <el-option label="登记人" value="user"></el-option>
  23. </el-select>
  24. <el-input
  25. v-model="myData.searchKey"
  26. placeholder="请输入"
  27. style="width: 217px"
  28. ></el-input>
  29. <span>日期范围:</span>
  30. <el-date-picker
  31. v-model="time"
  32. type="daterange"
  33. range-separator="-"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. >
  37. </el-date-picker>
  38. <el-button style="margin-left: 20px" @click="inquire">查询</el-button>
  39. </div>
  40. <!--表格 -->
  41. <div class="table">
  42. <el-table
  43. :header-cell-style="{ background: '#d8dff0', color: '#404040' }"
  44. :data="tableData"
  45. border
  46. style="width: 100%"
  47. >
  48. <el-table-column prop="name" label="藏品名称" :resizable="false">
  49. </el-table-column>
  50. <el-table-column prop="num" label="总登记号" width="280" :resizable="false">
  51. </el-table-column>
  52. <el-table-column prop="realName" label="登记人" width="200" :resizable="false">
  53. </el-table-column>
  54. <el-table-column prop="updateTime" label="编辑日期" width="200" :resizable="false">
  55. </el-table-column>
  56. <el-table-column prop="status" label="状态" width="230" :resizable="false">
  57. </el-table-column>
  58. <el-table-column label="操作" width="295" :resizable="false">
  59. <template #default='{row}'>
  60. <el-button type="text" @click="myLook(row)" v-if="row.status!=='待审核'">查看</el-button>
  61. <el-button type="text" @click="audit(row)" v-if="row.status==='待审核'" v-show="userLimits.audit">审核</el-button>
  62. <el-button type="text" @click="delData(row.id,row.status)" v-if="row.status!=='已完成'" v-show="userLimits.del" style="color:#C94848;">删除</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. </div>
  67. <!-- 分页器 -->
  68. <div class="paging">
  69. <el-pagination
  70. @current-change="currentChange"
  71. @size-change="sizeChange"
  72. background
  73. layout="prev, pager, next,sizes,jumper"
  74. :total="total"
  75. >
  76. </el-pagination>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import { getList, delData } from '@/apis/statistics2'
  85. import TabList from '@/components/tabLeft3.vue'
  86. export default {
  87. name: 'statistics2',
  88. components: { TabList },
  89. data () {
  90. return {
  91. userLimits: {
  92. del: false,
  93. audit: false
  94. }, // 用户权限数据
  95. total: 0,
  96. myData: {
  97. type: 'name',
  98. name: '',
  99. endTime: '', // 结束时间
  100. pageNum: 1, // 起始页码,默认1为第一页
  101. pageSize: 10, // 每页数量
  102. searchKey: '', // 搜索条件
  103. startTime: '', // 开始时间
  104. status: null // 状态,不传返回全部,0:草稿中, 1:待审核, 2:审核不通过, 3:审核通过,
  105. },
  106. // 选择状态的变量
  107. stateInd: 0,
  108. stateArr: [
  109. { txt: '全部', num: 0 },
  110. { txt: '待审核', num: 0 },
  111. { txt: '已完成', num: 0 },
  112. { txt: '审核不通过', num: 0 }
  113. ],
  114. type: '',
  115. time: '',
  116. // 表格数据
  117. tableData: []
  118. }
  119. },
  120. // 监听属性 类似于data概念
  121. computed: {},
  122. // 监控data中的数据变化
  123. watch: {
  124. // 处理时间
  125. time (val) {
  126. this.handleSelect(val)
  127. }
  128. },
  129. // 方法集合
  130. methods: {
  131. // 点击查询
  132. inquire () {
  133. this.myData.pageNum = 1
  134. this.getList(this.myData)
  135. },
  136. // 分页器
  137. currentChange (val) {
  138. // console.log('当前页改变了', val)
  139. // this.myData.sourceId = null
  140. // this.myData.searchKey = ''
  141. // this.time = []
  142. // this.myData.endTime = ''
  143. // this.myData.startTime = ''
  144. this.myData.pageNum = val
  145. this.getList(this.myData)
  146. this.$nextTick(() => {
  147. // 所有dom加载完毕之后---要执行的代码
  148. setTimeout(() => {
  149. if (this.tableData.length === 0) {
  150. this.myData.pageNum = 1
  151. this.getList(this.myData)
  152. }
  153. }, 100)
  154. })
  155. },
  156. sizeChange (val) {
  157. // this.myData.sourceId = null
  158. // this.myData.searchKey = ''
  159. // this.time = []
  160. // this.myData.endTime = ''
  161. // this.myData.startTime = ''
  162. // console.log('条数改变了', val)
  163. this.myData.pageSize = val
  164. this.getList(this.myData)
  165. },
  166. // 点击上面的状态切换
  167. stateSelect (index) {
  168. if (index !== this.stateInd) {
  169. this.myData.pageNum = 1
  170. // 点击待审核
  171. if (index === 1) {
  172. this.myData.status = 1
  173. this.getList(this.myData)
  174. } else if (index === 2) {
  175. // 点击已完成
  176. this.myData.status = 3
  177. this.getList(this.myData)
  178. } else if (index === 3) {
  179. // 点击审核不通过
  180. this.myData.status = 2
  181. this.getList(this.myData)
  182. } else if (index === 0) {
  183. // 点击全部
  184. this.myData.status = ''
  185. this.getList(this.myData)
  186. }
  187. }
  188. this.stateInd = index
  189. }, // 点击查看
  190. myLook (val) {
  191. this.$router.push({
  192. path: '/layout/statistics2_look',
  193. query: val
  194. })
  195. },
  196. // 点击删除
  197. async delData (id, status) {
  198. this.$confirm('确定删除吗?', '提示', {
  199. confirmButtonText: '删除',
  200. cancelButtonText: '取消',
  201. type: 'warning'
  202. }).then(async () => {
  203. // 发请求删除
  204. await delData(id)
  205. // 发请求刷新页面
  206. this.getList(this.myData)
  207. // 更新顶部数据
  208. this.stateArr.forEach(v => {
  209. if (v.txt === status) v.num--
  210. })
  211. this.stateArr[0].num--
  212. this.$message({
  213. type: 'success',
  214. message: '删除成功!'
  215. })
  216. }).catch(() => {
  217. this.$message({
  218. type: 'info',
  219. message: '已取消.'
  220. })
  221. })
  222. },
  223. // 点击审核
  224. audit (val) {
  225. this.$router.push({
  226. path: '/layout/statistics2_audit',
  227. query: val
  228. })
  229. },
  230. // 封装获取列表方法
  231. async getList (data) {
  232. const res = await getList(data)
  233. this.total = res.data.total
  234. // console.log(666, res.data.list)
  235. this.tableData = res.data.list
  236. this.tableData.forEach(v => {
  237. v.status = this.myState(v.status)
  238. // v.updateTime = v.updateTime.slice(0, 10)
  239. // v.createTime = v.createTime.slice(0, 10)
  240. })
  241. },
  242. // 时间处理----------------
  243. handleSelect (e) {
  244. const date = []
  245. for (const i in e) {
  246. date.push(this.gettime(e[i]))
  247. }
  248. this.myData.startTime = date[0]
  249. if (date[1]) this.myData.endTime = date[1].replace('00:00:00', '23:59:59')
  250. },
  251. gettime (data) {
  252. const value = data.getFullYear() + '-' +
  253. this.checkTime(data.getMonth() + 1) + '-' +
  254. this.checkTime(data.getDate()) + ' ' +
  255. this.checkTime(data.getHours()) + ':' +
  256. this.checkTime(data.getMinutes()) + ':' +
  257. this.checkTime(data.getSeconds())
  258. return value
  259. },
  260. checkTime (i) {
  261. if (i < 10) {
  262. i = '0' + i
  263. }
  264. return i
  265. }
  266. },
  267. // 生命周期 - 创建完成(可以访问当前this实例)
  268. created () {
  269. this.getList(this.myData)
  270. },
  271. // 生命周期 - 挂载完成(可以访问DOM元素)
  272. async mounted () {
  273. // 进页面拿到所有数据
  274. const res = await getList({ ...this.myData, pageSize: 99999 })
  275. this.stateArr[0].num = res.data.list.length
  276. let num1 = 0
  277. let num2 = 0
  278. let num3 = 0
  279. res.data.list.forEach(v => {
  280. if (v.status === 1) num1++
  281. if (v.status === 3) num2++
  282. if (v.status === 2) num3++
  283. })
  284. this.stateArr[1].num = num1
  285. this.stateArr[2].num = num2
  286. this.stateArr[3].num = num3
  287. // 获取角色权限树
  288. let temp2 = localStorage.getItem('daliCK_limits')
  289. temp2 = JSON.parse(temp2)
  290. this.userLimits.del = temp2[7].children[0].authority
  291. this.userLimits.audit = temp2[7].children[1].authority
  292. // console.log(999, temp2[7])
  293. },
  294. beforeCreate () {}, // 生命周期 - 创建之前
  295. beforeMount () {}, // 生命周期 - 挂载之前
  296. beforeUpdate () {}, // 生命周期 - 更新之前
  297. updated () {}, // 生命周期 - 更新之后
  298. beforeDestroy () {}, // 生命周期 - 销毁之前
  299. destroyed () {}, // 生命周期 - 销毁完成
  300. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  301. }
  302. </script>
  303. <style lang='less' scoped>
  304. .holding {
  305. /deep/#mytitle>span{
  306. font-weight: 800;
  307. }
  308. display: flex;
  309. .right {
  310. width: 100%;
  311. .top {
  312. padding-left: 18px;
  313. display: flex;
  314. align-items: center;
  315. margin-left: 2px;
  316. height: 40px;
  317. }
  318. .conten {
  319. padding: 0 20px 40px;
  320. width: 100%;
  321. height: 829px;
  322. .middle {
  323. .title{
  324. height: 60px;
  325. border-bottom: 1px solid #ccc;
  326. margin: 0 25px;
  327. display: flex;
  328. align-items: center;
  329. color: black;
  330. .active{
  331. color: #3E5EB3;
  332. border-bottom: 2px solid #3E5EB3;
  333. }
  334. li {
  335. height: 60px;
  336. line-height: 60px;
  337. padding: 0 15px;
  338. text-align: center;
  339. margin-left: 40px;
  340. cursor: pointer;
  341. }
  342. }
  343. position: relative;
  344. width: 100%;
  345. height: 100%;
  346. background-color: #fff;
  347. .select {
  348. color: black;
  349. padding: 30px 0 0 0;
  350. & > span {
  351. margin-left: 30px;
  352. }
  353. }
  354. .table {
  355. max-height: 580px;
  356. max-width: 1710px;
  357. // overflow: auto;
  358. padding: 24px;
  359. /deep/.el-table__body-wrapper{
  360. max-height: 510px;
  361. overflow-y: auto;
  362. }
  363. }
  364. .paging {
  365. position: absolute;
  366. bottom: 15px;
  367. left: 50%;
  368. transform: translateX(-50%);
  369. }
  370. }
  371. }
  372. }
  373. }
  374. </style>