assetsTable.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="table-container">
  3. <div class="table-list" :style="tableData && tableData.length?'height:calc(100% - 50px);':'height:100%;'">
  4. <el-table :data="tableData" style="width: 100%;" height="100%" v-loading="loading" :header-cell-style="headerStyle">
  5. <el-table-column label="所属建筑楼层" show-overflow-tooltip min-width="100">
  6. <template slot-scope="scope">
  7. <div>
  8. {{scope.row.Building?scope.row.Building.BuildLocalName?scope.row.Building.BuildLocalName:'':''}} -
  9. {{scope.row.Floor?scope.row.Floor.FloorLocalName?scope.row.Floor.FloorLocalName:'':''}}
  10. </div>
  11. </template>
  12. </el-table-column>
  13. <el-table-column prop="EquipLocalID" :label="`${inSpaceType}本地名称`" show-overflow-tooltip min-width="100"></el-table-column>
  14. <el-table-column prop="EquipLocalName" :label="`${inSpaceType}本地编码`" show-overflow-tooltip min-width="100"></el-table-column>
  15. <el-table-column prop="EquipFamily.FamilyName" label="设备族" show-overflow-tooltip min-width="100"></el-table-column>
  16. <el-table-column prop="InstallLocation" label="安装位置" show-overflow-tooltip min-width="100"></el-table-column>
  17. <el-table-column prop="TaskState" label="任务执行情况" show-overflow-tooltip min-width="100"></el-table-column>
  18. <el-table-column prop="action" label="操作" min-width="100">
  19. <template slot-scope="scope">
  20. <i v-if="scope.row.TaskState == '待验证' || scope.row.TaskState == '未找到'" title="查看详情" class="iconfont icon-xiangqing table-button" @click="handleDetail(scope.$index, scope.row)"></i>
  21. <i v-if="scope.row.TaskState == '未找到'" title="重新生成任务" class="iconfont icon-Update table-button" @click="handleRegenerate(scope.$index, scope.row)"></i>
  22. <i v-if="scope.row.TaskState == '待验证'" title="删除任务" class="iconfont icon-delete table-button" @click="handleDelete(scope.$index, scope.row)"></i>
  23. <i v-if="scope.row.TaskState == '未找到'" title="认可此任务执行情况" class="iconfont icon-lijiqueren table-button" @click="handleConfirm(scope.$index, scope.row)"></i>
  24. </template>
  25. </el-table-column>
  26. <template slot="empty">
  27. <div style="height: 60%;transform: translateY(50%);">
  28. <i class="icon-wushuju iconfont"></i>
  29. 数据暂无
  30. </div>
  31. </template>
  32. </el-table>
  33. </div>
  34. <el-pagination class="right" v-show="tableData && tableData.length" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page.pageNumber"
  35. :page-sizes="page.pageSizes" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="page.total">
  36. </el-pagination>
  37. <el-drawer title="任务详情" :visible.sync="drawer" direction="rtl" size="600px">
  38. <assets-detail :detail="detailAssets"></assets-detail>
  39. </el-drawer>
  40. </div>
  41. </template>
  42. <script>
  43. import { queryAssetsTask, deleteAssetsTask, createAssetsTask, updateAssetsTask } from "@/api/data_admin/buildTaskApi"
  44. import tools from "@/utils/tools"
  45. import { mapGetters } from "vuex"
  46. import assetsDetail from '../detail/assetsDetail'
  47. export default {
  48. components: {
  49. assetsDetail
  50. },
  51. computed: {
  52. ...mapGetters("layout", ["projectId", "userInfo"])
  53. },
  54. props: {
  55. paramsData: Object,
  56. },
  57. data() {
  58. return {
  59. inSpaceType: '资产',
  60. loading: false, // loading
  61. drawer: false, // 详情侧弹窗
  62. detailAssets: {},
  63. tableData: [], //列表数据
  64. page: {
  65. pageSize: 50,
  66. pageSizes: [10, 20, 50, 100],
  67. pageNumber: 1,
  68. total: 0
  69. },
  70. taskStateMap: {
  71. '-1': '未找到',
  72. '0': '已完成',
  73. '1': '待验证'
  74. },
  75. headerStyle: {
  76. backgroundColor: '#e1e4e5',
  77. color: '#2b2b2b',
  78. lineHeight: '30px'
  79. }, // 列表样式
  80. };
  81. },
  82. methods: {
  83. // 获取列表数据
  84. getTableData() {
  85. this.loading = true
  86. let params = {
  87. Filters: `ProjectId='${this.projectId}'`,
  88. Cascade: [
  89. {
  90. Name: 'equipFamily'
  91. }, {
  92. Name: 'scanScheme'
  93. }, {
  94. Name: 'building',
  95. }, {
  96. Name: 'floor',
  97. }
  98. ],
  99. Orders: "CreateTime desc, TaskId asc",
  100. PageNumber: this.page.pageNumber,
  101. PageSize: this.page.pageSize
  102. }
  103. if (this.paramsData.buildfloor[0] == "noKnow") {
  104. params.Filters += `;BuildingId isNull`
  105. } else if (this.paramsData.buildfloor[0] && this.paramsData.buildfloor[0] != "all") {
  106. params.Filters += `;BuildingId='${this.paramsData.buildfloor[0]}'`
  107. if (this.paramsData.buildfloor[1] == "noKnow") {
  108. params.Filters += `;FloorId isNull`
  109. } else if (this.paramsData.buildfloor[1] && this.paramsData.buildfloor[1] != "all") {
  110. params.Filters += `;FloorId='${this.paramsData.buildfloor[1]}'`
  111. }
  112. }
  113. if(this.paramsData.taskState !== ''){
  114. params.Filters += `;TaskState=${this.paramsData.taskState}`
  115. }
  116. if(this.paramsData.family){
  117. params.Filters += `;Category='${this.paramsData.family}'`
  118. }
  119. queryAssetsTask(params, res => {
  120. this.loading = false
  121. this.page.total = res.Total;
  122. this.tableData = res.Content.map(item => {
  123. item.TaskState = this.taskStateMap[item.TaskState]
  124. return item
  125. })
  126. })
  127. },
  128. // 删除关系
  129. handleDelete(index, row) {
  130. this.$confirm("确认删除该任务?", "提示", {
  131. confirmButtonText: '确定',
  132. cancelButtonText: '取消',
  133. type: 'warning'
  134. }).then(() => {
  135. let params = [{TaskId: row.TaskId}]
  136. deleteAssetsTask(params, res => {
  137. this.$message.success('删除成功')
  138. this.getTableData()
  139. })
  140. }).catch(() => {
  141. this.$message("取消删除")
  142. })
  143. },
  144. //重新生成任务
  145. handleRegenerate(index, row){
  146. let params = {
  147. Content: [{
  148. EquipId: row.EquipId,
  149. TaskState: -1
  150. }]
  151. }
  152. createAssetsTask(params, res => {
  153. this.$message.success('重新生成任务成功!')
  154. this.getTableData()
  155. })
  156. },
  157. //认可此任务执行情况
  158. handleConfirm(index, row){
  159. let params = {
  160. Content: [{
  161. ConfirmingPersonId: this.userInfo.userId,
  162. ConfirmingPersonName: this.userInfo.userName,
  163. TaskId: row.TaskId,
  164. TaskState: 0
  165. }]
  166. }
  167. updateAssetsTask(params, res => {
  168. this.$message.success('更新成功!')
  169. this.getTableData()
  170. })
  171. },
  172. //查看任务详情
  173. handleDetail(index, row) {
  174. this.drawer = true
  175. this.detailAssets = row
  176. },
  177. // 改变pagesize
  178. handleSizeChange(pageSize) {
  179. this.page.pageNumber = 1
  180. this.page.pageSize = pageSize;
  181. this.getTableData()
  182. },
  183. // 改变pageno
  184. handleCurrentChange(pageNo) {
  185. this.page.pageNumber = pageNo;
  186. this.getTableData()
  187. }
  188. },
  189. watch: {
  190. paramsData: {
  191. handler(newName, oldName) {
  192. if(!tools.isSimilarly(newName, oldName)){
  193. this.page.pageNumber = 1
  194. this.getTableData()
  195. }
  196. },
  197. immediate: true,
  198. deep: true
  199. },
  200. projectId() {
  201. this.page.pageNumber = 1
  202. this.getTableData()
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang="less" scoped>
  208. /deep/ .el-drawer__body {
  209. height: calc(100% - 80px);
  210. border-top: 1px solid #c9c9c9;
  211. }
  212. /deep/ .el-drawer__header {
  213. margin-bottom: 12px;
  214. }
  215. .table-container {
  216. height: 100%;
  217. background: #fff;
  218. .table-button{
  219. cursor: pointer;
  220. margin-right: 15px;
  221. }
  222. }
  223. </style>