addDeviceTask.vue 9.6 KB

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