modelTaskDialog.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogVisible" :before-close="handleClose" width="900px" id="addEqDialog">
  3. <div class="table-box">
  4. <el-table :data="tableData" style="width: 100%" height="350" v-loading="loading" :header-cell-style="headerStyle"
  5. ref="multipleTable"
  6. @selection-change="handleSelectionChange">
  7. <el-table-column type="selection" width="55"></el-table-column>
  8. <el-table-column type="expand">
  9. <template slot-scope="props">
  10. <p v-if="props.row.ComponentCount && props.row.ComponentCount.length"
  11. style="color:#99a9bf;line-height:32px;font-size:14px;">包含的部件:</p>
  12. <el-form label-position="left" label-width="auto" inline class="demo-table-expand"
  13. v-if="props.row.ComponentCount && props.row.ComponentCount.length">
  14. <el-form-item v-for="item in props.row.ComponentCount?props.row.ComponentCount:[]" :key="item.code"
  15. :label="`${item.name}:`">
  16. <span>{{ item.count }}</span>
  17. </el-form-item>
  18. </el-form>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="FolderName" label="所属模型文件夹" width="110" show-overflow-tooltip></el-table-column>
  22. <el-table-column prop="FileName" label="模型文件名" width="80" show-overflow-tooltip></el-table-column>
  23. <el-table-column label="设备本地名称" show-overflow-tooltip width="100">
  24. <template slot-scope="scope">
  25. <div>
  26. {{ scope.row.EquipLocalName }}
  27. <el-badge v-if="scope.row.Component&&scope.row.Component.length?true:false"
  28. :value="scope.row.Component&&scope.row.Component.length?scope.row.Component.length:0"
  29. class="item" type="warning">
  30. </el-badge>
  31. </div>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="EquipLocalID" label="设备本地编码" show-overflow-tooltip width="100"></el-table-column>
  35. <el-table-column prop="EquipCategory.EquipName" label="设备类" show-overflow-tooltip width="120"></el-table-column>
  36. <el-table-column prop="BIMID" label="BIM Id" show-overflow-tooltip width="80"></el-table-column>
  37. <el-table-column prop="type" label="现场验证操作规定" width="150">
  38. <template slot-scope="scope">
  39. <el-select style="width:100px;" v-model="scope.row.SchemeId" placeholder="请选择">
  40. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  41. </el-select>
  42. </template>
  43. </el-table-column>
  44. <template slot="empty">
  45. <div style="height: 60%;transform: translateY(50%);">
  46. <i class="icon-wushuju iconfont"></i>
  47. 暂无数据
  48. </div>
  49. </template>
  50. </el-table>
  51. <!-- 分页 -->
  52. <el-pagination class="fr" v-show="tableData && tableData.length" @size-change="handleSizeChange"
  53. @current-change="handleCurrentChange"
  54. :current-page="page.pageNumber" :page-sizes="page.pageSizes" :page-size="page.pageSize"
  55. layout="total, sizes, prev, pager, next, jumper"
  56. :total="page.total"></el-pagination>
  57. </div>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button size="small" @click="$emit('update:dialogVisible',false)">返回重选</el-button>
  60. <el-button size="small" type="primary" @click="savaRelation">确认创建</el-button>
  61. </span>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import { queryEquip } from "@/api/object/equip";
  66. import { createModelTask, queryModelDiglog } from "@/api/data_admin/buildTaskApi"
  67. import { mapGetters } from "vuex"
  68. export default {
  69. components: {},
  70. computed: {
  71. ...mapGetters("layout", ["projectId"])
  72. },
  73. data() {
  74. return {
  75. title: "确认创建任务",
  76. options: [{//方案
  77. value: '1',
  78. label: '极简'
  79. }, {
  80. value: '2',
  81. label: '标准'
  82. }],
  83. tableData: [],
  84. loading: false,
  85. selections: [], // 选中项
  86. page: {
  87. pageSize: 50,
  88. pageSizes: [10, 20, 50, 100],
  89. pageNumber: 1,
  90. total: 0
  91. },
  92. headerStyle: {
  93. backgroundColor: '#e1e4e5',
  94. color: '#2b2b2b',
  95. lineHeight: '30px'
  96. } // 列表样式
  97. };
  98. },
  99. props: {
  100. dialogVisible: Boolean,//是否显示弹窗
  101. params: Object, //模型和设备的信息
  102. newTaskTypes: Array
  103. },
  104. created() {
  105. },
  106. methods: {
  107. getTableData() {
  108. this.loading = true
  109. let params = {
  110. cascade: [
  111. {
  112. name: "equipCategory",
  113. projection: ["equipCode", "equipName"]
  114. },
  115. {
  116. name: "component",
  117. cascade: [{ name: "equipCategory" }]
  118. },
  119. {
  120. name: "building",
  121. projection: ["localName", "name", "id"]
  122. },
  123. {
  124. name: "floor",
  125. projection: ["localName", "name", "id"]
  126. }
  127. ],
  128. filters: `projectId='${this.projectId}'`,
  129. orders: "createTime desc, equipID asc",
  130. pageNumber: this.page.pageNumber,
  131. pageSize: this.page.pageSize
  132. }
  133. if (this.params.isVerification) {
  134. // params.Filters += `;(TaskState isNull || TaskState=0 || TaskState=-1)`
  135. // params.Filters += `;(TaskState!=0 || TaskState!=-1 || TaskState!=1)`
  136. params.filters += `;taskState isnull`
  137. } else {
  138. // params.Filters += `;(TaskState!=1)`
  139. params.filters += `;(taskState isnull or taskState !=1 )`
  140. }
  141. if (this.params.device) {
  142. params.filters += `;classCode='${this.params.device}'`
  143. }
  144. if (this.params.spaceList && this.params.spaceList.length) {
  145. //通过平面图区域查询
  146. // console.log(this.params,'this.params')
  147. let arr = []
  148. this.params.spaceList.forEach(i => {
  149. let list = `${this.projectId}${this.params.modelFolderId}${this.params.modelFileName}:${i}`
  150. arr.push(list)
  151. })
  152. let param = {
  153. ModelId: this.params.CurrentModelId,
  154. IdList: arr,
  155. Category: this.params.device || '',
  156. filters: `classCode='${this.params.device || ''}'`,
  157. PageNumber: this.page.pageNumber,
  158. PageSize: this.page.pageSize
  159. }
  160. // console.log(param,'param')
  161. queryModelDiglog(param, res => {
  162. this.loading = false
  163. this.dataFormatter(res)
  164. })
  165. } else {
  166. params.filters += `;modelId='${this.params.CurrentModelId}'`
  167. queryEquip(params, res => {
  168. this.loading = false
  169. this.dataFormatter(res)
  170. })
  171. }
  172. },
  173. // 表格数据格式化
  174. dataFormatter(res) {
  175. this.tableData = res.Content.map(item => {
  176. if (item.Component && item.Component.length) {
  177. item.ComponentCount = []
  178. item.Component.map(parts => {
  179. if (parts.EquipCategory && parts.EquipCategory.EquipCode && parts.EquipCategory.EquipName) {
  180. let index = item.ComponentCount.findIndex(c => {
  181. return c.code == parts.EquipCategory.EquipCode
  182. })
  183. if (index != -1) {
  184. item.ComponentCount[index].count++
  185. } else {
  186. item.ComponentCount.push({
  187. name: parts.EquipCategory.EquipName,
  188. code: parts.EquipCategory.EquipCode,
  189. count: 1
  190. })
  191. }
  192. }
  193. })
  194. }
  195. item.FolderName = this.params.modelFolderName
  196. item.FolderId = this.params.modelFolderId
  197. item.FileName = this.params.modelFileName
  198. item.FileId = this.params.CurrentModelId
  199. // 后端定义默认值(前端取消默认值设定)
  200. // item.SchemeId = "1"
  201. return item
  202. })
  203. this.page.total = res.Total
  204. },
  205. //选中项修改
  206. handleSelectionChange(val) {
  207. this.selections = val;
  208. },
  209. savaRelation() {
  210. if (this.selections.length) {
  211. let list = this.selections.map((item) => {
  212. if (item.SchemeId) {
  213. return {
  214. EquipId: item.EquipID,
  215. FileId: item.FileId,
  216. FileName: item.FileName,
  217. FolderId: item.FolderId,
  218. FolderName: item.FolderName,
  219. SchemeId: item.SchemeId
  220. }
  221. } else {
  222. return {
  223. EquipId: item.EquipID,
  224. FileId: item.FileId,
  225. FileName: item.FileName,
  226. FolderId: item.FolderId,
  227. FolderName: item.FolderName
  228. }
  229. }
  230. })
  231. let params = {
  232. Content: list
  233. }
  234. createModelTask(params, res => {
  235. this.$emit('update:dialogVisible', false)
  236. this.$message.success('创建成功!')
  237. this.$router.push({ name: 'buildTask', query: { newTaskTypes: this.newTaskTypes } })//跳转回首页
  238. })
  239. } else {
  240. this.$message('请选择要创建的任务!')
  241. }
  242. },
  243. //改变pagesize
  244. handleSizeChange(pageSize) {
  245. this.page.pageSize = pageSize;
  246. this.getTableData();
  247. },
  248. //改变pageno
  249. handleCurrentChange(pageNo) {
  250. this.page.pageNumber = 1
  251. this.page.pageNumber = pageNo;
  252. this.getTableData();
  253. },
  254. handleClose() {//关闭弹窗
  255. this.$emit('update:dialogVisible', false);
  256. }
  257. },
  258. watch: {
  259. dialogVisible(newData, oldData) {
  260. if (newData) {
  261. this.tableData = []
  262. this.page.pageNumber = 1
  263. this.getTableData()
  264. }
  265. }
  266. },
  267. };
  268. </script>
  269. <style lang="less" scoped>
  270. #addEqDialog {
  271. .filters {
  272. margin-bottom: 10px;
  273. /deep/ .el-input__inner {
  274. vertical-align: baseline;
  275. }
  276. }
  277. .table-box {
  278. height: 370px;
  279. .fr {
  280. margin-top: 10px;
  281. }
  282. }
  283. }
  284. </style>
  285. <style>
  286. .demo-table-expand {
  287. font-size: 0;
  288. }
  289. .demo-table-expand label {
  290. width: 90px;
  291. color: #99a9bf;
  292. }
  293. .demo-table-expand .el-form-item {
  294. margin-right: 0;
  295. margin-bottom: 0;
  296. margin-left: 120px;
  297. width: 100%;
  298. }
  299. </style>