addDeviceTask.vue 9.4 KB

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