changeRea.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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, getBussines, 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. // "limit": { // 分页查询, 选填.
  232. // "skip": this.page.size * (this.page.currentPage - 1), // 跳过多少数据
  233. // "count": this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
  234. // },
  235. // filter: {
  236. // EquipLocalName: this.search
  237. // },
  238. // "criteria": {
  239. // "id": "", // 选填, 默认值是Pj****, 即查询项目下的所有设备
  240. // "family": ["XXX"] // 必填, 要查询的类型, 只能是设备类型
  241. // }
  242. // },
  243. // secret: this.$route.query.secret,
  244. // ProjId: this.$route.query.projId
  245. // }
  246. // if (this.mess.buildId == "all") {
  247. // param.data.criteria.id = this.mess.ProjId
  248. // } else if (this.mess.buildId == "noKnow") {
  249. // param.data.criteria.id = this.mess.ProjId
  250. // param.data.directOnly = true
  251. // } else if (this.mess.floorId == "noKnow") {
  252. // param.data.criteria.id = this.mess.buildId
  253. // param.data.directOnly = true
  254. // } else if (this.mess.floorId && this.mess.floorId != "all") {
  255. // param.data.criteria.id = this.mess.floorId
  256. // } else if (this.mess.floorId == 'all') {
  257. // param.data.criteria.id = this.mess.buildId
  258. // } else {
  259. // param.data.criteria.id = this.$route.query.projId
  260. // }
  261. // console.log("category", this.category)
  262. // param.data.criteria.family = [this.getType(this.category.category)]
  263. // getBillPropList(param, res => {
  264. // console.log(res)
  265. // this.tableData = res.Content
  266. // this.page.total = res.Count
  267. // })
  268. let param = {
  269. data: {
  270. filter: {
  271. EquipLocalName: this.search
  272. },
  273. directOnly: false,
  274. criteria: {
  275. id: "",
  276. graphType: "Pe2Eq",
  277. side: -1,
  278. type: ""
  279. }
  280. },
  281. secret: this.secret,
  282. ProjId: this.projectId
  283. }
  284. if (this.mess.buildId == "all") {
  285. param.data.criteria.id = this.mess.ProjId
  286. } else if (this.mess.buildId == "noKnow") {
  287. param.data.criteria.id = this.mess.ProjId
  288. param.data.directOnly = true
  289. } else if (this.mess.floorId == "noKnow") {
  290. param.data.criteria.id = this.mess.buildId
  291. param.data.directOnly = true
  292. } else if (this.mess.floorId && this.mess.floorId != "all") {
  293. param.data.criteria.id = this.mess.floorId
  294. } else if (this.mess.floorId == 'all') {
  295. param.data.criteria.id = this.mess.buildId
  296. } else {
  297. param.data.criteria.id = this.$route.query.projId
  298. }
  299. param.data.criteria.type = [this.getType(this.category.category)]
  300. console.log(param)
  301. getBussines(param).then(res => {
  302. this.tableData = res.data.Content
  303. console.log(this.tableData, "this.tableData")
  304. this.page.total = res.data.Count
  305. })
  306. },
  307. getType(code) {
  308. console.log(code, "code")
  309. console.log(code.substring(2, 6))
  310. let system = code.substring(2, 6), myCode = ""
  311. this.codeListCode.map(item => {
  312. if (!!item.content && item.content.length) {
  313. item.content.map(child => {
  314. if (child.code == system) {
  315. myCode = item.code
  316. }
  317. })
  318. }
  319. })
  320. console.log(myCode)
  321. return myCode
  322. }
  323. },
  324. watch: {
  325. dialog: {
  326. deep: true,
  327. handler: function () {
  328. if (this.dialog.changeRea) {
  329. this.changePage()
  330. this.radio = ""
  331. }
  332. }
  333. }
  334. }
  335. };
  336. </script>
  337. <style lang="less">
  338. #changeRea {
  339. .el-table thead {
  340. tr {
  341. th {
  342. background-color: #f5f7fa;
  343. }
  344. }
  345. }
  346. }
  347. </style>