modelTaskDialog.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. },
  56. computed: {
  57. ...mapGetters("layout", ["projectId"])
  58. },
  59. data() {
  60. return {
  61. title: "确认创建任务",
  62. options: [{//方案
  63. value: '1',
  64. label: '极简'
  65. }, {
  66. value: '2',
  67. label: '标准'
  68. }],
  69. tableData: [],
  70. loading: false,
  71. selections: [], // 选中项
  72. page: {
  73. pageSize: 50,
  74. pageSizes: [10, 20, 50, 100],
  75. pageNumber: 1,
  76. total: 0
  77. },
  78. headerStyle: {
  79. backgroundColor: '#e1e4e5',
  80. color: '#2b2b2b',
  81. lineHeight: '30px'
  82. } // 列表样式
  83. };
  84. },
  85. props: {
  86. dialogVisible: Boolean,//是否显示弹窗
  87. params: Object, //模型和设备的信息
  88. newTaskTypes: Array
  89. },
  90. created() {
  91. },
  92. methods: {
  93. getTableData() {
  94. this.loading = true
  95. let params = {
  96. Cascade: [
  97. {
  98. Name: "equipCategory",
  99. Projection: ["EquipCode", "EquipName"]
  100. },
  101. {
  102. Name: "component",
  103. Cascade: [{ Name: "equipCategory" }]
  104. },
  105. {
  106. Name: "building",
  107. Projection: ["BuildLocalName", "BuildName", "BuildID"]
  108. },
  109. {
  110. Name: "floor",
  111. Projection: ["FloorLocalName", "FloorName", "FloorID"]
  112. }
  113. ],
  114. Filters: `ProjectId='${this.projectId}'`,
  115. Orders: "CreateTime desc, EquipID asc",
  116. PageNumber: this.page.pageNumber,
  117. PageSize: this.page.pageSize
  118. }
  119. if (this.params.isVerification) {
  120. params.Filters += `;(TaskState isNull || TaskState=0)`
  121. }
  122. if (this.params.device) {
  123. params.Filters += `;Category='${this.params.device}'`
  124. }
  125. if (this.params.spaceList && this.params.spaceList.length) {
  126. //通过平面图区域查询
  127. params.IdList = this.params.spaceList
  128. queryModelDiglog(params, res => {
  129. this.dataFormatter(res)
  130. })
  131. } else {
  132. params.Filters += `;ModelId='${this.params.CurrentModelId}'`
  133. queryEquip(params, res => {
  134. this.loading = false
  135. this.dataFormatter(res)
  136. })
  137. }
  138. },
  139. // 表格数据格式化
  140. dataFormatter(res) {
  141. this.tableData = res.Content.map(item => {
  142. if (item.Component && item.Component.length) {
  143. item.ComponentCount = []
  144. item.Component.map(parts => {
  145. if (parts.EquipCategory && parts.EquipCategory.EquipCode && parts.EquipCategory.EquipName) {
  146. let index = item.ComponentCount.findIndex(c => { return c.code == parts.EquipCategory.EquipCode })
  147. if (index != -1) {
  148. item.ComponentCount[index].count++
  149. } else {
  150. item.ComponentCount.push({
  151. name: parts.EquipCategory.EquipName,
  152. code: parts.EquipCategory.EquipCode,
  153. count: 1
  154. })
  155. }
  156. }
  157. })
  158. }
  159. item.FolderName = this.params.modelFolderName
  160. item.FolderId = this.params.modelFolderId
  161. item.FileName = this.params.modelFileName
  162. item.FileId = this.params.CurrentModelId
  163. // 后端定义默认值(前端取消默认值设定)
  164. // item.SchemeId = "1"
  165. return item
  166. })
  167. this.page.total = res.Total
  168. },
  169. //选中项修改
  170. handleSelectionChange(val) {
  171. this.selections = val;
  172. },
  173. savaRelation() {
  174. if (this.selections.length) {
  175. let list = this.selections.map((item) => {
  176. if (item.SchemeId) {
  177. return {
  178. EquipId: item.EquipID,
  179. FileId: item.FileId,
  180. FileName: item.FileName,
  181. FolderId: item.FolderId,
  182. FolderName: item.FolderName,
  183. SchemeId: item.SchemeId
  184. }
  185. } else {
  186. return {
  187. EquipId: item.EquipID,
  188. FileId: item.FileId,
  189. FileName: item.FileName,
  190. FolderId: item.FolderId,
  191. FolderName: item.FolderName
  192. }
  193. }
  194. })
  195. let params = {
  196. Content: list
  197. }
  198. createModelTask(params, res => {
  199. this.$emit('update:dialogVisible', false)
  200. this.$message.success('创建成功!')
  201. this.$router.push({ name: 'buildTask', query: { newTaskTypes: this.newTaskTypes } })//跳转回首页
  202. })
  203. } else {
  204. this.$message('请选择要创建的任务!')
  205. }
  206. },
  207. //改变pagesize
  208. handleSizeChange(pageSize) {
  209. this.page.pageSize = pageSize;
  210. this.getTableData();
  211. },
  212. //改变pageno
  213. handleCurrentChange(pageNo) {
  214. this.page.pageNumber = 1
  215. this.page.pageNumber = pageNo;
  216. this.getTableData();
  217. },
  218. handleClose() {//关闭弹窗
  219. this.$emit('update:dialogVisible', false);
  220. }
  221. },
  222. watch: {
  223. dialogVisible(newData, oldData) {
  224. if (newData) {
  225. this.tableData = []
  226. this.page.pageNumber = 1
  227. this.getTableData()
  228. }
  229. }
  230. },
  231. };
  232. </script>
  233. <style lang="less" scoped>
  234. #addEqDialog {
  235. .filters {
  236. margin-bottom: 10px;
  237. /deep/ .el-input__inner {
  238. vertical-align: baseline;
  239. }
  240. }
  241. .table-box {
  242. height: 370px;
  243. .fr {
  244. margin-top: 10px;
  245. }
  246. }
  247. }
  248. </style>
  249. <style>
  250. .demo-table-expand {
  251. font-size: 0;
  252. }
  253. .demo-table-expand label {
  254. width: 90px;
  255. color: #99a9bf;
  256. }
  257. .demo-table-expand .el-form-item {
  258. margin-right: 0;
  259. margin-bottom: 0;
  260. margin-left: 120px;
  261. width: 100%;
  262. }
  263. </style>