modelTaskDialog.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. 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`
  120. }
  121. if (this.params.device) {
  122. params.Filters += `;Category='${this.params.category}'`
  123. }
  124. if (this.params.spaceList && this.params.spaceList.length) {
  125. //通过平面图区域查询
  126. params.IdList = this.params.spaceList
  127. queryModelDiglog(params, res => {
  128. this.dataFormatter(res)
  129. })
  130. } else {
  131. params.Filters += `;ModelId='${this.params.CurrentModelId}'`
  132. queryEquip(params, res => {
  133. this.dataFormatter(res)
  134. })
  135. }
  136. },
  137. // 表格数据格式化
  138. dataFormatter(res) {
  139. this.tableData = res.Content.map(item => {
  140. if (item.Component && item.Component.length) {
  141. item.ComponentCount = []
  142. item.Component.map(parts => {
  143. if (parts.EquipCategory && parts.EquipCategory.EquipCode && parts.EquipCategory.EquipName) {
  144. let index = item.ComponentCount.findIndex(c => { return c.code == parts.EquipCategory.EquipCode })
  145. if (index != -1) {
  146. item.ComponentCount[index].count++
  147. } else {
  148. item.ComponentCount.push({
  149. name: parts.EquipCategory.EquipName,
  150. code: parts.EquipCategory.EquipCode,
  151. count: 1
  152. })
  153. }
  154. }
  155. })
  156. }
  157. item.FolderName = this.params.modelFolderName
  158. item.FolderId = this.params.modelFolderId
  159. item.FileName = this.params.modelFileName
  160. item.FileId = this.params.CurrentModelId
  161. item.SchemeId = "1"
  162. return item
  163. })
  164. this.page.total = res.Total
  165. },
  166. //选中项修改
  167. handleSelectionChange(val) {
  168. this.selections = val;
  169. },
  170. savaRelation() {
  171. if (this.selections.length) {
  172. let list = this.selections.map((item) => {
  173. return {
  174. EquipId: item.EquipID,
  175. FileId: item.FileId,
  176. FileName: item.FileName,
  177. FolderId: item.FolderId,
  178. FolderName: item.FolderName
  179. }
  180. })
  181. let params = {
  182. Content: list
  183. }
  184. createModelTask(params, res => {
  185. this.$emit('update:dialogVisible', false)
  186. this.$message.success('创建成功!')
  187. this.$router.push({ name: 'buildTask', query: { newTaskTypes: this.newTaskTypes } })//跳转回首页
  188. })
  189. } else {
  190. this.$message('请选择要创建的任务!')
  191. }
  192. },
  193. //改变pagesize
  194. handleSizeChange(pageSize) {
  195. this.page.pageSize = pageSize;
  196. this.getTableData();
  197. },
  198. //改变pageno
  199. handleCurrentChange(pageNo) {
  200. this.page.pageNumber = 1
  201. this.page.pageNumber = pageNo;
  202. this.getTableData();
  203. },
  204. handleClose() {//关闭弹窗
  205. this.$emit('update:dialogVisible', false);
  206. }
  207. },
  208. watch: {
  209. dialogVisible(newData, oldData) {
  210. if (newData) {
  211. this.tableData = []
  212. this.page.pageNumber = 1
  213. this.getTableData()
  214. }
  215. }
  216. },
  217. };
  218. </script>
  219. <style lang="less" scoped>
  220. #addEqDialog {
  221. .filters {
  222. margin-bottom: 10px;
  223. /deep/ .el-input__inner {
  224. vertical-align: baseline;
  225. }
  226. }
  227. .table-box {
  228. height: 370px;
  229. .fr {
  230. margin-top: 10px;
  231. }
  232. }
  233. }
  234. </style>
  235. <style>
  236. .demo-table-expand {
  237. font-size: 0;
  238. }
  239. .demo-table-expand label {
  240. width: 90px;
  241. color: #99a9bf;
  242. }
  243. .demo-table-expand .el-form-item {
  244. margin-right: 0;
  245. margin-bottom: 0;
  246. margin-left: 120px;
  247. width: 100%;
  248. }
  249. </style>