RelationMaintain.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="relation-maintain">
  3. <!--计算无需配置源末端的关系时提示-->
  4. <el-dialog
  5. :title="values.title"
  6. :visible.sync="dialogTableVisible"
  7. >
  8. <span class="font-big">{{values.autoComputed}}</span>
  9. <footer
  10. slot="footer"
  11. class="dialog-footer "
  12. >
  13. <el-button @click="dialogTableVisible = false">{{values.cancel}}</el-button>
  14. <el-button
  15. type="primary"
  16. @click="promptly"
  17. >{{values.promptly}}
  18. </el-button>
  19. </footer>
  20. </el-dialog>
  21. <!-- 计算需配置源末端的关系且已配置时提示-->
  22. <el-dialog
  23. :title="values.title"
  24. :visible.sync="dialogTableVisibleMore"
  25. >
  26. <div
  27. v-loading="TableVisibleMoreLoading"
  28. style="overflow:hidden"
  29. >
  30. <p class="font-big">{{values.existComputed}}</p>
  31. <p class="exist-title">{{values.existTitle}}</p>
  32. <el-row :span="24">
  33. <el-col :span="8">
  34. <span class="demonstration">{{values.originEquipment}}</span>
  35. <el-cascader
  36. :options="newOptions"
  37. :key="isResouceShow"
  38. v-model="ops"
  39. :props="props"
  40. @change="sourceOptions"
  41. collapse-tags
  42. clearable
  43. />
  44. </el-col>
  45. <el-col :span="8">
  46. <span class="demonstration">{{values.endEquipment}}</span>
  47. <!-- v-model="filterOps"
  48. -->
  49. <el-cascader
  50. :options="disOptions"
  51. :props="props"
  52. collapse-tags
  53. clearable
  54. />
  55. </el-col>
  56. </el-row>
  57. <footer
  58. slot="footer"
  59. class="dialog-footer "
  60. style="float: right"
  61. >
  62. <el-button @click="dialogTableVisibleMore = false">{{values.cancel}}</el-button>
  63. <el-button
  64. type="primary"
  65. @click="computedUpdate"
  66. >{{values.promptly}}
  67. </el-button>
  68. </footer>
  69. </div>
  70. </el-dialog>
  71. <!--设定设备对象源/末端-->
  72. <el-dialog
  73. :title="values.title"
  74. :visible.sync="dialogEquipment"
  75. >
  76. <span class="font-big">{{values.underDesign}}</span>
  77. <footer
  78. slot="footer"
  79. class="dialog-footer"
  80. >
  81. <el-button
  82. type="primary"
  83. @click="dialogEquipment = false"
  84. >{{values.confirm}}
  85. </el-button>
  86. </footer>
  87. </el-dialog>
  88. <!--手动编辑:提示引导-->
  89. <el-dialog
  90. :title="values.title"
  91. :visible.sync="dialogManualTip"
  92. >
  93. <p class="font-big">{{values.tips}}</p>
  94. <p
  95. class="font-big"
  96. v-for="item in values.device"
  97. >{{item}}</p>
  98. <footer
  99. slot="footer"
  100. class="dialog-footer "
  101. >
  102. <el-button @click="dialogManualTip = false">{{values.confirm}}
  103. </el-button>
  104. </footer>
  105. </el-dialog>
  106. <!--手动编辑:手动维护-->
  107. <el-dialog
  108. :title="values.title"
  109. :visible.sync="dialogManualOption"
  110. >
  111. <p class="option-tip">{{values.optionTips}}</p>
  112. <el-row :span="24">
  113. <el-col :span="8">
  114. <p>
  115. <i class="iconfont icon-doc-line"/>
  116. {{values.currentNum}} 0
  117. </p>
  118. <a href="/api/datacenter/graphic/template-downloads">
  119. <el-button
  120. type="primary"
  121. class="mt-10"
  122. >
  123. {{values.download}}
  124. </el-button>
  125. </a>
  126. </el-col>
  127. <el-col :span="10">
  128. {{values.lastTime}}
  129. </el-col>
  130. </el-row>
  131. <el-upload
  132. class="upload-demo"
  133. drag
  134. action="/api/datacenter/graphic/import"
  135. multiple
  136. name="fileName"
  137. :on-progress="progress"
  138. :on-success="success"
  139. :on-error="error"
  140. >
  141. <i class="el-icon-upload"/>
  142. <div
  143. class="el-upload__text"
  144. v-html="values.uploadTxt"
  145. />
  146. <div class="upload__tip danger" slot="tip">{{ values.uploadTips}}</div>
  147. </el-upload>
  148. </el-dialog>
  149. <!--手动编辑:手动维护.process结束-->
  150. <el-dialog
  151. :title="values.title"
  152. :visible.sync="dialogProcess"
  153. >
  154. <div class="block">
  155. <el-timeline>
  156. <el-timeline-item
  157. v-for="(activity, index) in activities"
  158. :key="index"
  159. :icon="activity.icon"
  160. :type="activity.type"
  161. :color="activity.color"
  162. :size="activity.size"
  163. >
  164. {{activity.content}}
  165. </el-timeline-item>
  166. </el-timeline>
  167. </div>
  168. <!-- 下载报告-->
  169. <a href="/api/datacenter//graphic/report-downloads">
  170. <el-button>{{values.downloadFile}}</el-button>
  171. </a>
  172. <footer
  173. slot="footer"
  174. class="dialog-footer "
  175. >
  176. <el-button @click="errBack">{{values.back}}</el-button>
  177. <el-button
  178. type="primary"
  179. @click="finish"
  180. >{{values.done}}
  181. </el-button>
  182. </footer>
  183. </el-dialog>
  184. </div>
  185. </template>
  186. <script>
  187. export default {
  188. name: "RelationMaintain",
  189. props: ['values', 'isComputed', 'source', 'TableVisibleMoreLoading'],
  190. created() {
  191. },
  192. mounted() {
  193. },
  194. data() {
  195. return {
  196. dialogTableVisible: false,
  197. dialogTableVisibleMore: false,
  198. dialogEquipment: false,
  199. dialogManualTip: false,
  200. dialogManualOption: false,
  201. dialogProcess: false,
  202. originEquipment: [],
  203. endEquipment: [],
  204. props: {
  205. multiple: true,
  206. label: 'FamilyName',
  207. value: 'lId',
  208. children: 'Items',
  209. }, // 级联
  210. activities: [{
  211. content: '数据文件处理中..',
  212. size: 'large',
  213. type: 'primary',
  214. icon: 'el-icon-check',
  215. color: '#0bbd87'
  216. }, {
  217. content: '数据处理失败',
  218. color: '#0bbd87',
  219. icon: 'el-icon-check',
  220. size: 'large',
  221. type: 'primary',
  222. }],
  223. vals: [],
  224. val: [],
  225. idArr: [],//存储所有选择的id
  226. secondary: [],//单独存储二级数据
  227. list: [],//获取后台数据,重新组合,添加唯一标识和源端标识
  228. isResouceShow: 0,
  229. result: [],//最终传给后台的数据
  230. ops: [],//第一个选择器model
  231. filterOps: [],//为清空第二个选择器
  232. }
  233. },
  234. computed:{
  235. fileHeaders() {
  236. return {'Content-Type': 'multipart/form-data'}
  237. },
  238. newOptions() {
  239. ++this.isResouceShow
  240. let allList = []
  241. this.deepCopy(this.source).forEach(item => allList.push(...item.Items))
  242. this.list = allList.map((item, index) => {
  243. item = {
  244. ...item,
  245. lId: index
  246. }
  247. item.Items.map(i => {
  248. i.lId = i.Id + i.BlockId //添加唯一标识
  249. i.Source = true //判断源末端
  250. return i
  251. })
  252. return item
  253. })
  254. this.ops = this.list
  255. return this.list
  256. },
  257. // 末端数据添加disabled
  258. disOptions() {
  259. let arr = this.deepCopy(this.list).map(item => {
  260. item.Items.map(i => {
  261. if (this.idArr.includes(i.lId)) {
  262. i.disabled = true
  263. }
  264. return i
  265. })
  266. return item
  267. })
  268. this.filterOps = arr
  269. return arr
  270. }
  271. },
  272. methods: {
  273. deepCopy(obj) {
  274. return JSON.parse(JSON.stringify(obj))
  275. },
  276. progress(event, file, fileList) {
  277. // console.log(event.file, fileList)
  278. },
  279. success(event, file, fileList) {
  280. this.dialogManualOption = true
  281. this.dialogProcess = true
  282. console.log(event.file, fileList,' file success')
  283. },
  284. error(event, file, fileList) {
  285. this.dialogManualOption = true
  286. this.dialogProcess = true
  287. console.log(event.file, fileList)
  288. },
  289. errBack() {
  290. this.dialogProcess = false
  291. },
  292. finish() {
  293. this.dialogProcess = false
  294. this.dialogManualOption = false
  295. },
  296. templateDownload() {
  297. this.$emit('template')
  298. },
  299. promptly() {
  300. console.log(this.isComputed, 'child isComputed')
  301. this.dialogTableVisible = false
  302. },
  303. sourceOptions(val) {
  304. //把所有id组装到一个数组
  305. this.idArr = val.map(item => item[1])
  306. //提取后台二级数据
  307. this.secondary = []
  308. this.deepCopy(this.list).forEach(item => this.secondary.push(...item.Items))
  309. //最终过滤
  310. let filterList = this.secondary.filter(item => this.idArr.includes(item.lId))
  311. // 组合成接口需要的数据格式
  312. let result = []
  313. filterList.forEach(item => {
  314. let {BlockId, BuildingId, Domain, Id, MepSystemType, ProjectId, Source, SourceId, Type, Statistics} = item
  315. result.push({
  316. BlockId,
  317. BuildingId,
  318. Domain,
  319. // Id,
  320. MepSystemType,
  321. ProjectId,
  322. Source,
  323. SourceId,
  324. SourceType: Type,
  325. Statistics
  326. })
  327. })
  328. this.result = result
  329. },
  330. computedUpdate() {
  331. if (!this.result.length) {
  332. this.$message({
  333. showClose: true,
  334. message: '请选择源端设备类',
  335. type: 'warning'
  336. });
  337. return false
  338. } else {
  339. this.$emit('openComputed', this.result)
  340. this.dialogTableVisibleMore = false
  341. }
  342. }
  343. }
  344. }
  345. </script>
  346. <style scoped lang="less">
  347. .relation-maintain {
  348. .mt-10 {
  349. margin-top: 10px;
  350. }
  351. .danger {
  352. color: #d9001b;
  353. }
  354. .font-big {
  355. font-weight: 600;
  356. }
  357. .exist-title {
  358. font-size: 12px;
  359. color: #AAAAAA;
  360. }
  361. .option-tip {
  362. font-size: 18px;
  363. font-weight: 600;
  364. }
  365. .upload-demo {
  366. margin: 20px 0;
  367. }
  368. /deep/ .el-upload-dragger {
  369. width: 600px;
  370. margin: 0 auto;
  371. }
  372. }
  373. </style>