modelTaskDialog.vue 9.3 KB

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