changeRea.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <!--
  2. changeRea 厂商
  3. -->
  4. <template>
  5. <el-dialog title="关联资产" :visible.sync="dialog.changeRea" width="800px">
  6. <div>
  7. <div id="changeRea">
  8. <div class="title-search" style="margin-bottom: 10px;">
  9. <el-input
  10. placeholder="输入名称查询"
  11. v-model="search"
  12. size="small"
  13. style="width:300px;"
  14. clearable
  15. ></el-input>
  16. <el-button @click="getData" size="small">查找</el-button>
  17. </div>
  18. <div>
  19. <floor-cascader @change="changeFloor"></floor-cascader>
  20. </div>
  21. <el-radio-group v-model="radio" style="width:100%;">
  22. <el-table :data="tableData" style="width: 100%" height="300px">
  23. <el-table-column label="资产名称">
  24. <template slot-scope="scope">
  25. <el-radio
  26. v-model="radio"
  27. :label="scope.row.id"
  28. >{{scope.row.infos.EquipLocalName || scope.row.infos.EquipName}}</el-radio>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="本地编码">
  32. <template
  33. slot-scope="scope"
  34. >{{scope.row.infos.EquipLocalID || scope.row.infos.EquipID}}</template>
  35. </el-table-column>
  36. <el-table-column prop="name" label="所在楼层">
  37. <template slot-scope="scope">{{getFloor(scope.row.relation)}}</template>
  38. </el-table-column>
  39. <el-table-column label="设备族">
  40. <template slot-scope="scope">{{getFramily(scope.row.family)}}</template>
  41. </el-table-column>
  42. <el-table-column label="安装位置">
  43. <template slot-scope="scope">{{scope.row.infos.InstallLocation || "--"}}</template>
  44. </el-table-column>
  45. </el-table>
  46. </el-radio-group>
  47. <my-pagination :page="page" @change="changed" style="margin-top:10px;"></my-pagination>
  48. <div class="footer">
  49. <el-button
  50. type="primary"
  51. @click="clickTrue"
  52. style="display:block;margin: 10px auto 0;"
  53. >确 定</el-button>
  54. </div>
  55. </div>
  56. </div>
  57. <param-details :isLoad="isLoad" :data="data"></param-details>
  58. </el-dialog>
  59. </template>
  60. <script>
  61. import myPagination from "@/components/ledger/lib/myPagination";
  62. import paramDetails from "@/components/dialogs/list/paramDetails"
  63. import { getBillPropList, getEquipmentFamily, getSpaceFloor, getBussines2, upDateTableMain } from "@/api/scan/request"
  64. import floorCascader from "@/components/ledger/lib/floorCascader";
  65. import {mapGetters, mapActions} from "vuex"
  66. export default {
  67. components: {
  68. myPagination,
  69. paramDetails,
  70. floorCascader
  71. },
  72. props: {
  73. dialog: {
  74. type: Object,
  75. default: function () {
  76. return {
  77. changeRea: true
  78. };
  79. }
  80. },
  81. category: {
  82. type: Object,
  83. default: function () {
  84. return {}
  85. }
  86. }
  87. },
  88. data() {
  89. return {
  90. search: "", //搜索文案
  91. radio: "",
  92. tableData: [
  93. ],
  94. data: {},
  95. isLoad: {
  96. paramShow: false
  97. },
  98. page: {
  99. size: 50,
  100. sizes: [10, 30, 50, 100, 150, 200],
  101. total: 0,
  102. currentPage: 1
  103. },
  104. mess: {},
  105. codeListCode: [],
  106. floorList: []
  107. };
  108. },
  109. created() {
  110. this.getCode()
  111. },
  112. computed: {
  113. ...mapGetters("layout", [
  114. "projectId",
  115. "secret",
  116. "userId"
  117. ])
  118. },
  119. mounted() { },
  120. methods: {
  121. getFloor(relation) {
  122. let floor = !!relation ? relation.floor || "" : ""
  123. if (!!floor) {
  124. console.log(floor)
  125. let floorName = ""
  126. this.floorList.map(item => {
  127. if (!!item.floors && item.floors.length) {
  128. item.floors.map(child => {
  129. if (child.id == floor) {
  130. floorName = child.infos.FloorLocalName || child.infos.FloorName
  131. }
  132. })
  133. }
  134. })
  135. return floorName
  136. } else {
  137. return "--"
  138. }
  139. },
  140. clickTrue() {
  141. if (!!this.radio) {
  142. let param = {
  143. UserId: this.userId,
  144. ProjId: this.projectId
  145. }
  146. let paramList = [{
  147. EquipmentId: this.category.id,
  148. FmId: this.radio
  149. }]
  150. console.log(param, paramList)
  151. upDateTableMain(param, paramList).then(res => {
  152. this.$emit("close")
  153. this.dialog.changeRea = false
  154. })
  155. // upDateTableMain(param, res => {
  156. // })
  157. } else {
  158. this.$message("请先选择资产")
  159. }
  160. },
  161. getFramily(code) {
  162. console.log(code)
  163. let name = ""
  164. this.codeListCode.map(item => {
  165. if (item.code == code) {
  166. name = item.name
  167. }
  168. })
  169. return name || "--"
  170. },
  171. getCode() {
  172. getEquipmentFamily(res => {
  173. this.codeListCode = res.Content
  174. this.getFloorList()
  175. })
  176. },
  177. getFloorList() {
  178. let param = {
  179. secret: this.secret,
  180. ProjId: this.projectId
  181. }
  182. getSpaceFloor(param).then(res => {
  183. if (res.data.Result == "success") {
  184. this.floorList = res.data.Content
  185. } else {
  186. this.$message.error("请求错误:" + res.data.ResultMsg)
  187. }
  188. }).catch(_ => {
  189. this.$message.error("请求错误")
  190. })
  191. },
  192. changeFloor(val) {
  193. this.mess = {
  194. buildId: val[0] || "",
  195. floorId: val[1] || ""
  196. }
  197. this.getData()
  198. console.log(val)
  199. },
  200. changed() {
  201. this.getData()
  202. },
  203. //查询技术参数
  204. lookParam(data) {
  205. this.data = data
  206. this.isLoad.paramShow = true
  207. },
  208. getChange() {
  209. if (!!this.radio) {
  210. this.$emit("changechangeRea", this.radio)
  211. this.dialog.changeRea = false
  212. } else {
  213. this.$message("请选择型号")
  214. }
  215. },
  216. searchKey() {
  217. this.changePage()
  218. },
  219. changePage() {
  220. this.page = {
  221. size: 50,
  222. sizes: [10, 30, 50, 100, 150, 200],
  223. total: 0,
  224. currentPage: 1
  225. }
  226. this.getData()
  227. },
  228. getData() {
  229. // let param = {
  230. // data: {
  231. // filter: {
  232. // EquipLocalName: this.search
  233. // },
  234. // directOnly: false,
  235. // criteria: {
  236. // id: "",
  237. // graphType: "Pe2Eq",
  238. // side: -1,
  239. // type: ""
  240. // }
  241. // },
  242. // secret: this.secret,
  243. // ProjId: this.projectId
  244. // }
  245. let param = {
  246. data: {
  247. directOnly: false,
  248. criteria: {
  249. EquipLocalName: [this.search == ""? null: this.search],
  250. id: "",
  251. type: [],
  252. exclude: [{
  253. graphType: "Pe2Eq",
  254. side: "fromId",
  255. }]
  256. }
  257. },
  258. secret: this.secret,
  259. ProjId: this.projectId
  260. }
  261. if (this.mess.buildId == "all") {
  262. param.data.criteria.id = this.mess.ProjId
  263. } else if (this.mess.buildId == "noKnow") {
  264. param.data.criteria.id = this.mess.ProjId
  265. param.data.directOnly = true
  266. } else if (this.mess.floorId == "noKnow") {
  267. param.data.criteria.id = this.mess.buildId
  268. param.data.directOnly = true
  269. } else if (this.mess.floorId && this.mess.floorId != "all") {
  270. param.data.criteria.id = this.mess.floorId
  271. } else if (this.mess.floorId == 'all') {
  272. param.data.criteria.id = this.mess.buildId
  273. } else {
  274. param.data.criteria.id = this.projectId
  275. }
  276. param.data.criteria.type = [this.getType(this.category.category)]
  277. console.log(param)
  278. getBussines2(param).then(res => {
  279. this.tableData = res.data.Content
  280. console.log(this.tableData, "this.tableData")
  281. this.page.total = res.data.Count
  282. })
  283. },
  284. getType(code) {
  285. console.log(code, "code")
  286. console.log(code.substring(2, 6))
  287. let system = code.substring(2, 6), myCode = ""
  288. this.codeListCode.map(item => {
  289. if (!!item.content && item.content.length) {
  290. item.content.map(child => {
  291. if (child.code == system) {
  292. myCode = item.code
  293. }
  294. })
  295. }
  296. })
  297. console.log(myCode)
  298. return myCode
  299. }
  300. },
  301. watch: {
  302. dialog: {
  303. deep: true,
  304. handler: function () {
  305. if (this.dialog.changeRea) {
  306. this.changePage()
  307. this.radio = ""
  308. }
  309. }
  310. }
  311. }
  312. };
  313. </script>
  314. <style lang="less">
  315. #changeRea {
  316. .el-table thead {
  317. tr {
  318. th {
  319. background-color: #f5f7fa;
  320. }
  321. }
  322. }
  323. }
  324. </style>