changeRea.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 placeholder="输入名称或编码查询" v-model="search" size="small" style="width:300px;" clearable></el-input>
  10. <el-button @click="getPropertyData" size="small">查找</el-button>
  11. </div>
  12. <div>
  13. <floor-cascader @change="changeFloor"></floor-cascader>
  14. </div>
  15. <el-radio-group v-model="radio" style="width:100%;">
  16. <el-table :data="tableData" style="width: 100%" height="300px">
  17. <el-table-column label="资产名称">
  18. <template slot-scope="scope">
  19. <el-radio :label="scope.row.EquipID" :ref="scope.row.EquipID" :value="scope.row.EquipLocalName || scope.row.EquipName">
  20. {{scope.row.EquipLocalName || scope.row.EquipName}}
  21. </el-radio>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="本地编码">
  25. <template slot-scope="scope">{{scope.row.EquipLocalID || scope.row.EquipID}}</template>
  26. </el-table-column>
  27. <el-table-column prop="name" label="所在楼层">
  28. <template slot-scope="scope">{{getFloor(scope.row.FloorId)}}</template>
  29. </el-table-column>
  30. <el-table-column label="设备族">
  31. <span>{{this.category.assetName}}</span>
  32. </el-table-column>
  33. <el-table-column label="安装位置">
  34. <template slot-scope="scope">
  35. {{scope.row.LedgerParam?scope.row.LedgerParam.Siteinstall?scope.row.LedgerParam.Siteinstall.InstallLocation:"--":"--"}}
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. </el-radio-group>
  40. <my-pagination :page="page" @change="changed" style="margin-top:10px;"></my-pagination>
  41. <div class="footer">
  42. <el-button type="primary" @click="clickTrue" style="display:block;margin: 10px auto 0;">确 定</el-button>
  43. </div>
  44. </div>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. import myPagination from "@/components/ledger/lib/myPagination";
  50. import paramDetails from "@/components/dialogs/list/paramDetails"
  51. import { getSpaceFloor, queryProperty } from "@/api/scan/request"
  52. import floorCascader from "@/components/ledger/lib/floorCascader";
  53. import { mapGetters, mapActions } from "vuex"
  54. export default {
  55. components: {
  56. myPagination,
  57. paramDetails,
  58. floorCascader
  59. },
  60. props: {
  61. dialog: {
  62. type: Object,
  63. default: function () {
  64. return {
  65. changeRea: true
  66. };
  67. }
  68. },
  69. category: {
  70. type: Object,
  71. default: function () {
  72. return {}
  73. }
  74. }
  75. },
  76. data() {
  77. return {
  78. search: "", //搜索文案
  79. radio: "",
  80. tableData: [],
  81. page: {
  82. size: 50,
  83. sizes: [10, 30, 50, 100, 150, 200],
  84. total: 0,
  85. currentPage: 1
  86. },
  87. mess: {},
  88. codeListCode: [],
  89. floorList: []
  90. };
  91. },
  92. created() {
  93. this.getFloorList();
  94. },
  95. computed: {
  96. ...mapGetters("layout", ["projectId", "secret", "userId"])
  97. },
  98. mounted() { },
  99. methods: {
  100. //根据楼层id对应楼层
  101. getFloor(relation) {
  102. let floor = !!relation ? relation.floor || "" : ""
  103. if (!!floor) {
  104. let floorName = ""
  105. this.floorList.map(item => {
  106. if (!!item.floors && item.floors.length) {
  107. item.floors.map(child => {
  108. if (child.id == floor) {
  109. floorName = child.infos.FloorLocalName || child.infos.FloorName
  110. }
  111. })
  112. }
  113. })
  114. return floorName
  115. } else {
  116. return "--"
  117. }
  118. },
  119. //确认选择
  120. clickTrue() {
  121. if (this.radio) {
  122. this.$emit('changeProperty', { PropertyId: this.radio, LinkEquipLocalName: this.$refs[this.radio].value });
  123. this.dialog.changeRea = false;
  124. } else {
  125. this.$message("请先选择资产")
  126. }
  127. },
  128. //查询条件-所在建筑楼层
  129. getFloorList() {
  130. let param = {
  131. secret: this.secret,
  132. ProjId: this.projectId
  133. }
  134. getSpaceFloor(param).then(res => {
  135. if (res.data.Result == "success") {
  136. this.floorList = res.data.Content
  137. } else {
  138. this.$message.error("请求错误:" + res.data.ResultMsg)
  139. }
  140. }).catch(_ => {
  141. this.$message.error("请求错误")
  142. })
  143. },
  144. //所在建筑楼层修改
  145. changeFloor(val) {
  146. this.mess = {
  147. buildId: val[0] || "",
  148. floorId: val[1] || ""
  149. }
  150. this.getPropertyData()
  151. },
  152. //分页修改
  153. changed() {
  154. this.getPropertyData()
  155. },
  156. //弹窗显示时
  157. changePage() {
  158. this.page = {
  159. size: 50,
  160. sizes: [10, 30, 50, 100],
  161. total: 0,
  162. currentPage: 1
  163. }
  164. this.getPropertyData()
  165. },
  166. //查询表数据
  167. getPropertyData() {
  168. let param = {
  169. Filters: `EquipmentId isNull;Family="${this.category.assetType}"`,
  170. PageNumber: this.page.currentPage,
  171. PageSize: this.page.size
  172. }
  173. //建筑id
  174. if (this.mess.buildId == "noKnow") {
  175. param.Filters += `;buildingId isNull`
  176. } else if (this.mess.buildId && this.mess.buildId != "all") {
  177. param.Filters += `;buildingId='${this.mess.buildId}'`
  178. }
  179. //楼层id
  180. if (this.mess.floorId == "noKnow") {
  181. param.Filters += `;floorId isNull`
  182. } else if (this.mess.floorId && this.mess.floorId != "all") {
  183. param.Filters += `;floorId='${this.mess.floorId}'`
  184. }
  185. //名称和编码
  186. if (this.search) {
  187. param.Filters += `;floorId='${this.mess.floorId}'`
  188. }
  189. queryProperty(param, res => {
  190. this.tableData = res.Content
  191. this.page.total = res.Total
  192. })
  193. }
  194. },
  195. watch: {
  196. dialog: {
  197. deep: true,
  198. handler: function () {
  199. if (this.dialog.changeRea) {
  200. this.changePage()
  201. this.radio = ""
  202. }
  203. }
  204. }
  205. }
  206. };
  207. </script>
  208. <style lang="less">
  209. #changeRea {
  210. .el-table thead {
  211. tr {
  212. th {
  213. background-color: #f5f7fa;
  214. }
  215. }
  216. }
  217. }
  218. </style>