index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. :formatter="formatRoomType"></el-table-column>
  51. <el-table-column prop="Building"
  52. min-width="10px"
  53. align="center"
  54. label="楼宇"
  55. show-overflow-tooltip
  56. :formatter="formatBuilding"></el-table-column>
  57. <el-table-column prop="PositionInformation"
  58. min-width="10px"
  59. align="center"
  60. label="位置信息"
  61. show-overflow-tooltip></el-table-column>
  62. <el-table-column prop="RoomDescribe"
  63. min-width="10px"
  64. align="center"
  65. label="实验室描述"
  66. show-overflow-tooltip></el-table-column>
  67. <el-table-column prop="CreateOn"
  68. min-width="10px"
  69. label="使用日期"
  70. align="center"
  71. show-overflow-tooltip>
  72. <template slot-scope="scope">
  73. {{ jstimehandle(scope.row.CreateOn + "") }}
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="操作"
  77. align="center"
  78. width="140px"
  79. fixed='right'>
  80. <template slot-scope="scope">
  81. <el-button size="mini"
  82. type="primary"
  83. title="编辑"
  84. @click="editmaintain(scope.row)"
  85. icon="el-icon-edit"
  86. circle></el-button>
  87. <!-- </router-link>&nbsp; -->
  88. <el-button size="mini"
  89. @click="deleteinstrument(scope.row)"
  90. type="danger"
  91. title="删除"
  92. style="margin-left:5px"
  93. icon="el-icon-delete"
  94. circle></el-button>
  95. <!-- <el-button size="mini"
  96. @click="openRoleUserDialog(scope.row)"
  97. type="warning"
  98. title="设备关联"
  99. style="margin-left:5px"
  100. icon="el-icon-star-off"
  101. circle></el-button> -->
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <addroom ref="addroom"
  106. @closeAddDialog="handleCloseAdd"
  107. @initdata="searchroomdata"
  108. :typeList="typeList"
  109. :buildingList="buildingList"></addroom>
  110. <editroom ref="editroom"
  111. @closeEditDialog="handleCloseEdit"
  112. @initdata="searchroomdata"
  113. :typeList="typeList"
  114. :buildingList="buildingList"></editroom>
  115. <role-user :role="role"
  116. v-model="roleUserDialogVisible" />
  117. <template slot="footer">
  118. <el-pagination style="margin: -10px;"
  119. @size-change="handleSizeChange"
  120. @current-change="handleCurrentChange"
  121. :current-page="currpage"
  122. :page-sizes="[10, 15, 20]"
  123. :page-size="size"
  124. layout="total, sizes, prev, pager, next, jumper"
  125. :total="totalsize">
  126. </el-pagination>
  127. </template>
  128. </d2-container>
  129. </template>
  130. <script>
  131. import {
  132. searchmanagingroomdata,
  133. deletemanagingrooms
  134. } from '@/api/instrumentroom'
  135. import addroom from './_opera/add'
  136. import editroom from './_opera/edit'
  137. import roleUser from './instrumentrooms'
  138. import itemDetailApi from '@/api/sysadmin/itemdetail'
  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. buildingList: [], // 楼宇
  158. name: '',
  159. totalsize: 0,
  160. currpage: 1,
  161. size: 10,
  162. entityList: [],
  163. search: {
  164. RoomNum: ''
  165. },
  166. typeList: [],
  167. InstrumenName: '',
  168. InstrumenCode: '',
  169. paramid: '',
  170. CreateBy: '',
  171. starttime: null,
  172. endtime: null,
  173. CreateOn: [], // 录入时期
  174. role: { Id: '', RoomName: '' },
  175. // 列表排序
  176. Column: {
  177. Order: '',
  178. Prop: ''
  179. }
  180. }
  181. },
  182. mounted () {
  183. this.searchroomdata()
  184. this.getRoomTypeList()
  185. this.getBuildingList()
  186. },
  187. methods: {
  188. // 获取所有实验室类型
  189. getRoomTypeList () {
  190. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'RoomType' })
  191. .then(res => {
  192. this.typeList = res
  193. })
  194. .catch(err => {
  195. console.error(err)
  196. })
  197. },
  198. formatRoomType (row, column) {
  199. for (var i = 0; i < this.typeList.length; i++) {
  200. if (parseInt(this.typeList[i].ItemValue) === parseInt(row.RoomType)) {
  201. return this.typeList[i].ItemName
  202. }
  203. }
  204. },
  205. formatBuilding (row, column) {
  206. for (var i = 0; i < this.buildingList.length; i++) {
  207. if (parseInt(this.buildingList[i].ItemValue) === parseInt(row.Building)) {
  208. return this.buildingList[i].ItemName
  209. }
  210. }
  211. },
  212. // 获取位置列表
  213. getBuildingList () {
  214. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Local' })
  215. .then(res => {
  216. this.buildingList = res
  217. })
  218. .catch(err => {
  219. console.error(err)
  220. })
  221. },
  222. // 添加 实验室
  223. maintainlogadd () {
  224. this.$refs.addroom.dialogvisible = true
  225. },
  226. // 添加 返回当前页面
  227. handleCloseAdd () {
  228. this.$refs.addroom.dialogvisible = false
  229. },
  230. // 编辑
  231. editmaintain (val) {
  232. this.$refs.editroom.testlistform = val
  233. this.$refs.editroom.dialogvisible = true
  234. },
  235. // 编辑 返回当前页面
  236. handleCloseEdit () {
  237. this.$refs.editroom.dialogvisible = false
  238. },
  239. // 初始化列表数据
  240. searchroomdata () {
  241. let _this = this
  242. let params = {
  243. RoomNum: this.search.RoomNum,
  244. _currentPage: this.currpage,
  245. _size: this.size,
  246. paramid: this.paramid,
  247. Order: this.Column.Order,
  248. Prop: this.Column.Prop
  249. }
  250. searchmanagingroomdata(params)
  251. .then(function (response) {
  252. _this.entityList = response.info.items
  253. _this.totalsize = response.info.currentItemCount
  254. })
  255. .catch(function (error) {
  256. console.log(error)
  257. })
  258. },
  259. openRoleUserDialog (role) {
  260. this.role = role
  261. this.roleUserDialogVisible = !this.roleUserDialogVisible
  262. },
  263. handleSizeChange (val) {
  264. this.size = val
  265. this.currpage = 1
  266. this.searchroomdata()
  267. },
  268. handleCurrentChange (val) {
  269. this.currpage = val
  270. this.searchroomdata()
  271. },
  272. jstimehandle (val) {
  273. if (val === '') {
  274. return '----'
  275. } else if (val === '0001-01-01T08:00:00+08:00') {
  276. return '----'
  277. } else if (val === '5000-01-01T23:59:59+08:00') {
  278. return '永久'
  279. } else {
  280. if (val === '0001-01-01T00:00:00Z') {
  281. return '----'
  282. } else val = val.replace('T', ' ')
  283. return val.substring(0, 19)
  284. }
  285. },
  286. // 删除设备信息
  287. deleteinstrument (val) {
  288. let _this = this
  289. _this
  290. .$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  291. confirmButtonText: '确定',
  292. cancelButtonText: '关闭',
  293. type: 'warning'
  294. })
  295. .then(() => {
  296. deletemanagingrooms(val.Id)
  297. .then(function (response) {
  298. // response
  299. if (response.info.code === 0) {
  300. _this.$message({
  301. type: 'success',
  302. message: response.info.message
  303. })
  304. // 更新界面
  305. _this.searchroomdata()
  306. } else {
  307. _this.$message({
  308. type: 'warning',
  309. message: response.info.message
  310. })
  311. }
  312. })
  313. .catch(function (error) {
  314. console.log(error)
  315. })
  316. })
  317. .catch(() => { })
  318. },
  319. // 列表排序功能
  320. orderby (column) {
  321. if (column.order === 'ascending') {
  322. this.Column.Order = 'asc'
  323. } else if (column.order === 'descending') {
  324. this.Column.Order = 'desc'
  325. }
  326. this.Column.Prop = column.prop
  327. this.searchroomdata()
  328. },
  329. searchCommand (command) {
  330. if (command === 'search') {
  331. this.dialogvisible = true
  332. } else if (command === 'clear') {
  333. this.clearSearch()
  334. }
  335. },
  336. clearSearch () {
  337. this.search.RoomNum = ''
  338. this.CreateOn = []
  339. this.searchroomdata()
  340. }
  341. }
  342. }
  343. </script>
  344. <style lang="scss">
  345. .el-pagination {
  346. margin: 1rem 0 2rem;
  347. text-align: right;
  348. }
  349. .plab {
  350. font-size: 13px;
  351. color: #999;
  352. }
  353. </style>