addAssetsTask.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="box">
  3. <div class="condition">
  4. <div class="header">
  5. <!-- <i style="float:left;font-size:30px;padding-right:10px;cursor:pointer;" title="返回" @click="goBack" class="el-icon-back"></i> -->
  6. <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
  7. <floor-cascader ref="floorCascader" @change="changeFloor"></floor-cascader>
  8. <my-cascader ref="cascader" @change="changeDevice"></my-cascader>
  9. <el-input placeholder="请输入安装位置" style="width: 200px;margin-left:20px;" v-model="keycode" clearable @keyup.enter.native="getTableData">
  10. <i slot="suffix" class="el-input__icon el-icon-search" style="cursor:pointer;" @click="getTableData"></i>
  11. </el-input>
  12. <el-button style="float:right;margin-top:1px;" @click="handleClickCreate">创建已选</el-button>
  13. </div>
  14. <div class="main" :style="tableData && tableData.length?'height: calc(100% - 96px);':'height: calc(100% - 46px);'">
  15. <el-table ref="multipleTable" :data="tableData" v-loading='loading' stripe height="100%" @selection-change="handleSelectionChange" :header-cell-style="headerStyle">
  16. <el-table-column type="selection" width="55"></el-table-column>
  17. <el-table-column label="所属建筑楼层" width="200">
  18. <template slot-scope="scope">
  19. <div>
  20. {{scope.row.Building?scope.row.Building.BuildLocalName?scope.row.Building.BuildLocalName:'':''}} -
  21. {{scope.row.Floor?scope.row.Floor.FloorLocalName?scope.row.Floor.FloorLocalName:'':''}}
  22. </div>
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="EquipLocalName" label="资产本地名称" show-overflow-tooltip></el-table-column>
  26. <el-table-column prop="EquipLocalID" label="资产本地编码" show-overflow-tooltip width="200"></el-table-column>
  27. <el-table-column prop="FamilyName.Name" label="设备族"></el-table-column>
  28. <el-table-column prop="LedgerParam.Siteinstall.InstallLocation" label="安装位置"></el-table-column>
  29. <template slot="empty">
  30. <div style="height: 60%;transform: translateY(50%);">
  31. <i class="icon-wushuju iconfont"></i>
  32. 数据暂无
  33. </div>
  34. </template>
  35. </el-table>
  36. </div>
  37. <div class=footer>
  38. <el-pagination
  39. class="right"
  40. v-show="tableData && tableData.length"
  41. @size-change="handleSizeChange"
  42. @current-change="handleCurrentChange"
  43. :current-page="page.pageNumber"
  44. :page-sizes="page.pageSizes"
  45. :page-size="page.pageSize"
  46. layout="total, sizes, prev, pager, next, jumper"
  47. :total="page.total">
  48. </el-pagination>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { mapGetters } from "vuex"
  55. //组件
  56. import floorCascader from "@/components/ledger/lib/floorCascader"
  57. import myCascader from "@/components/ledger/lib/assets"
  58. //api
  59. import { queryProperty } from "@/api/scan/request"
  60. import { createAssetsTask } from "@/api/data_admin/buildTaskApi"
  61. export default {
  62. data() {
  63. return {
  64. params: {},
  65. loading: false,
  66. keycode: '',
  67. page: {
  68. pageSize: 50,
  69. pageSizes: [10, 20, 50, 100],
  70. pageNumber: 1,
  71. total: 0
  72. },
  73. tableData: [],
  74. multipleSelection:[],
  75. headerStyle: {
  76. backgroundColor: '#e1e4e5',
  77. color: '#2b2b2b',
  78. lineHeight: '30px'
  79. }, // 列表样式
  80. }
  81. },
  82. computed: {
  83. ...mapGetters("layout", ["projectId", "userId", "secret"])
  84. },
  85. components: {
  86. floorCascader,
  87. myCascader
  88. },
  89. created() {
  90. this.params = this.$route.query
  91. },
  92. mounted() {
  93. this.getTableData()
  94. },
  95. watch: {
  96. projectId() {
  97. this.page.pageNumber = 1
  98. this.multipleSelection = []
  99. this.getTableData()
  100. }
  101. },
  102. methods: {
  103. //返回
  104. goBack() {
  105. this.$router.push({ name: "buildTask" })
  106. },
  107. //选择设备族
  108. changeDevice(val) {
  109. if(val.code) {
  110. this.params.category = val.code
  111. } else {
  112. this.params.category = ''
  113. }
  114. this.page.pageNumber = 1
  115. this.getTableData()
  116. },
  117. //选择建筑楼层
  118. changeFloor(value) {
  119. if (value[0]) {
  120. this.params.buildId = value[0]
  121. }
  122. if (value[1]) {
  123. this.params.floorId = value[1]
  124. } else {
  125. this.params.floorId = ''
  126. }
  127. this.page.pageNumber = 1
  128. this.getTableData()
  129. },
  130. //获取表格数据
  131. getTableData() {
  132. this.loading = true
  133. let param = this.formatFilter()
  134. queryProperty(param, res => {
  135. this.tableData = res.Content
  136. this.page.total = res.Total
  137. this.loading = false
  138. })
  139. },
  140. //格式化条件
  141. formatFilter() {
  142. let params = {
  143. Cascade: [
  144. {
  145. Name: "familyName"
  146. },
  147. {
  148. Name: "building",
  149. Projection: [ "BuildLocalName", "BuildName", "BuildID" ]
  150. },
  151. {
  152. Name: "floor",
  153. Projection: [ "FloorLocalName", "FloorName", "FloorID" ]
  154. }
  155. ],
  156. Filters: `ProjectId='${this.projectId}'`,
  157. Orders: "CreateTime desc, EquipID asc",
  158. PageNumber: this.page.pageNumber,
  159. PageSize: this.page.pageSize
  160. }
  161. if(this.params.isVerification){
  162. params.Filters += `;TaskState isNull`
  163. }
  164. if(this.keycode){
  165. params.Filters += `;LedgerParam.Siteinstall.InstallLocation contain '${this.keycode}'`
  166. }
  167. if(this.params.category){
  168. params.Filters += `;Family='${this.params.category}'`
  169. }
  170. if (this.params.buildId == "noKnow") {
  171. params.Filters += `;BuildingId isNull`
  172. } else if (this.params.buildId && this.params.buildId != "all") {
  173. params.Filters += `;BuildingId='${this.params.buildId}'`
  174. }
  175. if (this.params.floorId == "noKnow") {
  176. params.Filters += `;FloorId isNull`
  177. } else if (this.params.floorId && this.params.floorId != "all") {
  178. params.Filters += `;FloorId='${this.params.floorId}'`
  179. }
  180. return params
  181. },
  182. //选择的设备或部件
  183. handleSelectionChange(val) {
  184. this.multipleSelection = val;
  185. },
  186. //切换每页显示多少条数据
  187. handleSizeChange(val) {
  188. this.page.pageSize = val
  189. this.getTableData()
  190. },
  191. //切换页数
  192. handleCurrentChange(val) {
  193. this.page.pageNumber = 1
  194. this.page.pageNumber = val
  195. this.getTableData()
  196. },
  197. //创建已选
  198. handleClickCreate() {
  199. let list = this.multipleSelection.map((item) => {
  200. return {EquipId: item.EquipID}
  201. })
  202. let param = {
  203. Content: list
  204. }
  205. createAssetsTask(param, res => {
  206. this.$message.success("创建成功!")
  207. this.$router.push({ name: "buildTask" })
  208. })
  209. }
  210. }
  211. };
  212. </script>
  213. <style scoped lang='less'>
  214. .box {
  215. .condition {
  216. padding: 10px;
  217. display: flex;
  218. height: 100%;
  219. flex-direction: column;
  220. border: 1px solid #dfe6ec;
  221. background: #fff;
  222. margin-bottom: 10px;
  223. .header{
  224. padding-bottom: 10px;
  225. border-bottom: 1px solid #bcbcbc;
  226. }
  227. .main{
  228. margin-top: 10px;
  229. }
  230. }
  231. }
  232. </style>