index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <d2-container>
  3. <template slot="header"
  4. style="padding: 5px;">
  5. <el-form size="mini"
  6. ref="form"
  7. :inline="true"
  8. style="height: 25px; margin-top: -7px; padding:20px; text-align:right;">
  9. <el-form-item label="房间号">
  10. <el-input style="width:140px"
  11. v-model="search.RoomNum"
  12. placeholder="请输入房间号"></el-input>
  13. </el-form-item>
  14. <el-button size="mini"
  15. type="primary"
  16. @click="searchroomdata()"
  17. style="margin-left:10px"
  18. @command="searchCommand">查 询</el-button>
  19. <el-button size="mini"
  20. type="primary"
  21. @click="clearSearch">重 置</el-button>
  22. <el-button size="mini"
  23. type="primary"
  24. style="margin-right:6px"
  25. @click="maintainlogadd()">添加</el-button>
  26. </el-form>
  27. </template>
  28. <el-table ref="multipleTable"
  29. :data="entityList"
  30. border
  31. stripe
  32. tooltip-effect="dark"
  33. @sort-change="orderby"
  34. height="100%">
  35. <el-table-column prop="RoomNum"
  36. min-width="10px"
  37. align="center"
  38. label="房间号"
  39. show-overflow-tooltip></el-table-column>
  40. <el-table-column prop="RoomName"
  41. min-width="10px"
  42. align="center"
  43. label="房间名称"
  44. show-overflow-tooltip></el-table-column>
  45. <el-table-column prop="RoomType"
  46. min-width="10px"
  47. align="center"
  48. label="房间类型"
  49. show-overflow-tooltip>
  50. <template slot-scope="scope">
  51. {{ typeList[scope.row.RoomType] }}
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="RoomDescribe"
  55. min-width="10px"
  56. align="center"
  57. label="房间描述"
  58. show-overflow-tooltip></el-table-column>
  59. <el-table-column prop="PositionInformation"
  60. min-width="10px"
  61. align="center"
  62. label="位置信息"
  63. show-overflow-tooltip></el-table-column>
  64. <el-table-column prop="CreateBy"
  65. min-width="10px"
  66. align="center"
  67. label="使用人"
  68. show-overflow-tooltip></el-table-column>
  69. <el-table-column prop="CreateOn"
  70. min-width="10px"
  71. label="使用日期"
  72. align="center"
  73. show-overflow-tooltip>
  74. <template slot-scope="scope">
  75. {{ jstimehandle(scope.row.CreateOn + "") }}
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="操作"
  79. align="center"
  80. width="140px"
  81. fixed='right'>
  82. <template slot-scope="scope">
  83. <el-button size="mini"
  84. type="primary"
  85. title="编辑"
  86. @click="editmaintain(scope.row)"
  87. icon="el-icon-edit"
  88. circle></el-button>
  89. <!-- </router-link>&nbsp; -->
  90. <el-button size="mini"
  91. @click="deleteinstrument(scope.row)"
  92. type="danger"
  93. title="删除"
  94. style="margin-left:5px"
  95. icon="el-icon-delete"
  96. circle></el-button>
  97. <el-button size="mini"
  98. @click="openRoleUserDialog(scope.row)"
  99. type="warning"
  100. title="设备关联"
  101. style="margin-left:5px"
  102. icon="el-icon-star-off"
  103. circle></el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <addroom ref="addroom"
  108. @closeAddDialog="handleCloseAdd"
  109. @initdata="searchroomdata"></addroom>
  110. <editroom ref="editroom"
  111. @closeEditDialog="handleCloseEdit"
  112. @initdata="searchroomdata"></editroom>
  113. <role-user :role="role"
  114. v-model="roleUserDialogVisible" />
  115. <template slot="footer">
  116. <el-pagination style="margin: -10px;"
  117. @size-change="handleSizeChange"
  118. @current-change="handleCurrentChange"
  119. :current-page="currpage"
  120. :page-sizes="[10, 15, 20]"
  121. :page-size="size"
  122. layout="total, sizes, prev, pager, next, jumper"
  123. :total="totalsize">
  124. </el-pagination>
  125. </template>
  126. </d2-container>
  127. </template>
  128. <script>
  129. import {
  130. searchmanagingroomdata,
  131. deletemanagingrooms
  132. } from '@/api/instrumentroom'
  133. import addroom from './_opera/add'
  134. import editroom from './_opera/edit'
  135. import roleUser from './instrumentrooms'
  136. import {
  137. getroomtypelist
  138. } from '@/api/setting/samplenoteitem'
  139. export default {
  140. components: {
  141. addroom,
  142. editroom,
  143. roleUser
  144. },
  145. name: 'instrumentroom',
  146. data () {
  147. return {
  148. roleUserDialogVisible: false,
  149. selectedMaintainLogId: 0,
  150. dialogvisible: false,
  151. Id: 0,
  152. RoomNum: 0,
  153. RoomName: '',
  154. RoomType: '',
  155. RoomDescribe: '',
  156. PositionInformation: '',
  157. name: '',
  158. totalsize: 0,
  159. currpage: 1,
  160. size: 10,
  161. entityList: [],
  162. search: {
  163. RoomNum: ''
  164. },
  165. typeList: [],
  166. InstrumenName: '',
  167. InstrumenCode: '',
  168. paramid: '',
  169. CreateBy: '',
  170. starttime: null,
  171. endtime: null,
  172. CreateOn: [], // 录入时期
  173. role: { Id: '', RoomName: '' },
  174. // 列表排序
  175. Column: {
  176. Order: '',
  177. Prop: ''
  178. }
  179. }
  180. },
  181. mounted () {
  182. this.getroomtypelist()
  183. },
  184. methods: {
  185. // 获取所有房间类型
  186. getroomtypelist () {
  187. let _this = this
  188. getroomtypelist()
  189. .then(res => {
  190. for (let type of res.info) {
  191. _this.typeList[type.Value] = type.Key
  192. }
  193. this.searchroomdata()
  194. })
  195. .catch(err => {
  196. console.error(err)
  197. })
  198. },
  199. // 添加 房间
  200. maintainlogadd () {
  201. this.$refs.addroom.dialogvisible = true
  202. },
  203. // 添加 返回当前页面
  204. handleCloseAdd () {
  205. this.$refs.addroom.dialogvisible = false
  206. },
  207. // 编辑
  208. editmaintain (val) {
  209. this.$refs.editroom.dialogvisible = true
  210. this.$refs.editroom.testlistform.Id = val.Id
  211. this.$refs.editroom.testlistform.RoomNum = val.RoomNum
  212. this.$refs.editroom.testlistform.RoomName = val.RoomName
  213. this.$refs.editroom.testlistform.RoomType = val.RoomType
  214. this.$refs.editroom.testlistform.RoomDescribe = val.RoomDescribe
  215. this.$refs.editroom.testlistform.PositionInformation = val.PositionInformation
  216. },
  217. // 编辑 返回当前页面
  218. handleCloseEdit () {
  219. this.$refs.editroom.dialogvisible = false
  220. },
  221. // 初始化列表数据
  222. searchroomdata () {
  223. let _this = this
  224. let params = {
  225. RoomNum: this.search.RoomNum,
  226. _currentPage: this.currpage,
  227. _size: this.size,
  228. paramid: this.paramid,
  229. Order: this.Column.Order,
  230. Prop: this.Column.Prop
  231. }
  232. if (this.CreateOn && this.CreateOn.length === 2) {
  233. let params2 = {
  234. CreateOnstart: this.CreateOn[0] / 1000,
  235. CreateOnend: this.CreateOn[1] / 1000
  236. }
  237. params = Object.assign(params2)
  238. }
  239. searchmanagingroomdata(params)
  240. .then(function (response) {
  241. _this.entityList = response.info.items
  242. _this.totalsize = response.info.currentItemCount
  243. })
  244. .catch(function (error) {
  245. console.log(error)
  246. })
  247. },
  248. openRoleUserDialog (role) {
  249. this.role = role
  250. this.roleUserDialogVisible = !this.roleUserDialogVisible
  251. },
  252. handleSizeChange (val) {
  253. this.size = val
  254. this.currpage = 1
  255. this.searchroomdata()
  256. },
  257. handleCurrentChange (val) {
  258. this.currpage = val
  259. this.searchroomdata()
  260. },
  261. jstimehandle (val) {
  262. if (val === '') {
  263. return '----'
  264. } else if (val === '0001-01-01T08:00:00+08:00') {
  265. return '----'
  266. } else if (val === '5000-01-01T23:59:59+08:00') {
  267. return '永久'
  268. } else {
  269. if (val === '0001-01-01T00:00:00Z') {
  270. return '----'
  271. } else val = val.replace('T', ' ')
  272. return val.substring(0, 19)
  273. }
  274. },
  275. // 删除设备信息
  276. deleteinstrument (val) {
  277. let _this = this
  278. _this
  279. .$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  280. confirmButtonText: '确定',
  281. cancelButtonText: '关闭',
  282. type: 'warning'
  283. })
  284. .then(() => {
  285. deletemanagingrooms(val.Id)
  286. .then(function (response) {
  287. // response
  288. if (response.info.code === 0) {
  289. _this.$message({
  290. type: 'success',
  291. message: response.info.message
  292. })
  293. // 更新界面
  294. _this.searchroomdata()
  295. } else {
  296. _this.$message({
  297. type: 'warning',
  298. message: response.info.message
  299. })
  300. }
  301. })
  302. .catch(function (error) {
  303. console.log(error)
  304. })
  305. })
  306. .catch(() => { })
  307. },
  308. // 列表排序功能
  309. orderby (column) {
  310. if (column.order === 'ascending') {
  311. this.Column.Order = 'asc'
  312. } else if (column.order === 'descending') {
  313. this.Column.Order = 'desc'
  314. }
  315. this.Column.Prop = column.prop
  316. this.searchroomdata()
  317. },
  318. searchCommand (command) {
  319. if (command === 'search') {
  320. this.dialogvisible = true
  321. } else if (command === 'clear') {
  322. this.clearSearch()
  323. }
  324. },
  325. clearSearch () {
  326. this.search.RoomNum = ''
  327. this.CreateOn = []
  328. this.searchroomdata()
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="scss">
  334. .el-pagination {
  335. margin: 1rem 0 2rem;
  336. text-align: right;
  337. }
  338. .plab {
  339. font-size: 13px;
  340. color: #999;
  341. }
  342. </style>