index.vue 10 KB

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