index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. class="sbutton_padding"
  9. style="margin-top: -7px;text-align:right;">
  10. <el-form-item label="设备名称"
  11. class="sbutton_margin">
  12. <el-input style="width: 140px;"
  13. v-model="search.InstrumenName"
  14. placeholder="请输入设备名称"></el-input>
  15. </el-form-item>
  16. <el-form-item label="操作类型"
  17. class="sbutton_margin">
  18. <el-select v-model="search.OperaTpye"
  19. placeholder="请输入操作类型"
  20. clearable
  21. style="width:140px;">
  22. <el-option v-for="item in classificationlist"
  23. :label="item.Value"
  24. :value="item.Value"
  25. :key="item.Value"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <!-- <el-form-item label="操作人">
  29. <el-input v-model="search.OperaUser"
  30. style="width: 165px;"
  31. placeholder="输入操作人"></el-input>
  32. </el-form-item> -->
  33. <el-col :span="6"></el-col>
  34. <!-- <el-form-item label="操作日期"
  35. class="sbutton_margin">
  36. <el-date-picker style="width:220px"
  37. v-model="OperaOn"
  38. type="daterange"
  39. range-separator="至"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期"></el-date-picker>
  42. </el-form-item> -->
  43. <el-button size="mini"
  44. type="primary"
  45. style="margin-left:10px;"
  46. @click="searchdata()"
  47. class="sbutton_margin">查询</el-button>
  48. <el-button size="mini"
  49. type="primary"
  50. @click="clearSearch"
  51. class="sbutton_margin">重置</el-button>
  52. <el-button size="mini"
  53. type="primary"
  54. style="margin-right:6px;"
  55. @click="maintainlogadd()"
  56. class="sbutton_margin">添加</el-button>
  57. </el-form>
  58. </template>
  59. <el-table ref="multipleTable"
  60. :data="activities"
  61. border
  62. stripe
  63. tooltip-effect="dark"
  64. style="width: 100%"
  65. @sort-change="orderby"
  66. height="100%">
  67. <el-table-column label="操作"
  68. align="center"
  69. width="100px"
  70. fixed='right'>
  71. <template slot-scope="scope">
  72. <el-button size="mini"
  73. type="primary"
  74. title="编辑"
  75. @click="editmaintain(scope.row.Id)"
  76. icon="el-icon-edit"
  77. circle></el-button>
  78. <el-button size="mini"
  79. @click="deleteinstrument(scope.row)"
  80. type="danger"
  81. title="删除"
  82. style="margin-left:5px"
  83. icon="el-icon-delete"
  84. circle></el-button>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="InstrumenCode"
  88. align="center"
  89. label="设备编号"
  90. min-width="160"
  91. show-overflow-tooltip></el-table-column>
  92. <el-table-column prop="InstrumenName"
  93. align="center"
  94. label="设备名称"
  95. min-width="120"
  96. show-overflow-tooltip></el-table-column>
  97. <el-table-column prop="OperaTpye"
  98. align="center"
  99. label="操作类型"
  100. min-width="120"
  101. show-overflow-tooltip></el-table-column>
  102. <el-table-column prop="OperaUser"
  103. align="center"
  104. label="操作人"
  105. show-overflow-tooltip></el-table-column>
  106. <el-table-column prop="OperaRemark"
  107. align="center"
  108. label="操作说明"
  109. show-overflow-tooltip
  110. min-width="160px"></el-table-column>
  111. <el-table-column prop="OperaOn"
  112. sortable
  113. label="操作日期"
  114. align="center"
  115. show-overflow-tooltip
  116. min-width="120">
  117. <template slot-scope="scope">{{ jstimehandle(scope.row.OperaOn +'') }}</template>
  118. </el-table-column>
  119. </el-table>
  120. <!-- </el-card> -->
  121. <addmaintainlog ref="addmaintain"
  122. @closeAddDialog="handleCloseAdd"></addmaintainlog>
  123. <editmiantainlog ref="editmaintainlog"
  124. @closeAddDialog="handleCloseEdit"
  125. :maintainlogId="selectedMaintainLogId"></editmiantainlog>
  126. <!-- </div> -->
  127. <template slot="footer">
  128. <el-pagination style="margin: -10px;"
  129. @size-change="handleSizeChange"
  130. @current-change="handleCurrentChange"
  131. :current-page="currpage"
  132. :page-sizes="[10, 15, 20]"
  133. :page-size="size"
  134. layout="total, sizes, prev, pager, next, jumper"
  135. :total="totalsize">
  136. </el-pagination>
  137. </template>
  138. </d2-container>
  139. </template>
  140. <script>
  141. import {
  142. searchdatazl,
  143. OperaTpyelist,
  144. deleteinstrumentzl
  145. } from '@/api/instrumentroom'
  146. import addmaintainlog from './_opera/add'
  147. import editmiantainlog from './_opera/edit'
  148. export default {
  149. components: {
  150. addmaintainlog,
  151. editmiantainlog
  152. },
  153. name: 'instrument',
  154. data () {
  155. return {
  156. selectedMaintainLogId: 0,
  157. dialogvisible: false,
  158. name: '',
  159. totalsize: 0,
  160. currpage: 1,
  161. size: 10,
  162. OperaOn: [], // 录入时期
  163. activities: [],
  164. search: {
  165. OperaTpye: '',
  166. InstrumenName: '',
  167. InstrumenCode: '',
  168. OperaUser: ''
  169. },
  170. classificationlist: [],
  171. InstrumenName: '',
  172. InstrumenCode: '',
  173. addparam: '',
  174. paramid: '',
  175. OperaUser: '',
  176. // 列表排序
  177. Column: {
  178. Order: '',
  179. Prop: ''
  180. }
  181. }
  182. },
  183. mounted () {
  184. // searchdatazl()
  185. if (this.$route.query.id) {
  186. this.addparam = '?pid=' + this.$route.query.id
  187. this.paramid = this.$route.query.id
  188. this.search.InstrumenCode = ''
  189. this.search.InstrumenName = ''
  190. }
  191. this.searchdata()
  192. this.getOperaTpyelist()
  193. },
  194. methods: {
  195. maintainlogadd () {
  196. this.$refs.addmaintain.dialogvisible = true
  197. },
  198. editmaintain (maintainlogId) {
  199. this.$refs.editmaintainlog.getDonorsInfoAttachment(maintainlogId)
  200. this.$refs.editmaintainlog.dialogvisible = true
  201. this.$refs.editmaintainlog.initData(maintainlogId)
  202. this.selectedMaintainLogId = maintainlogId
  203. },
  204. // 添加 返回当前页面
  205. handleCloseAdd () {
  206. this.$refs.addmaintain.dialogvisible = false
  207. this.searchdata()
  208. },
  209. // 编辑 返回当前页面
  210. handleCloseEdit () {
  211. this.$refs.editmaintainlog.dialogvisible = false
  212. this.searchdata()
  213. },
  214. // 初始化列表数据
  215. searchdata () {
  216. let _this = this
  217. let OperaOn = []
  218. // let paramid
  219. if (!_this.OperaOn) {
  220. _this.OperaOn = []
  221. }
  222. // 解析时间
  223. if (_this.OperaOn.length === 2) {
  224. _this.OperaOn[1].setHours(23)
  225. _this.OperaOn[1].setMinutes(59)
  226. _this.OperaOn[1].setSeconds(59)
  227. OperaOn.push(_this.formatDateTime(_this.OperaOn[0]))
  228. OperaOn.push(_this.formatDateTime(_this.OperaOn[1]))
  229. }
  230. let params = {
  231. _currentPage: this.currpage,
  232. _size: this.size,
  233. InstrumenCode: this.search.InstrumenCode,
  234. InstrumenName: this.search.InstrumenName,
  235. OperaTpye: this.search.OperaTpye,
  236. OperaUser: this.search.OperaUser,
  237. paramid: this.paramid,
  238. Order: this.Column.Order,
  239. Prop: this.Column.Prop,
  240. TypeCode: 1
  241. }
  242. searchdatazl(params)
  243. .then(function (response) {
  244. _this.activities = response.info.items
  245. _this.totalsize = response.info.currentItemCount
  246. })
  247. .catch(function (error) {
  248. console.log(error)
  249. })
  250. },
  251. // 清除查询条件
  252. handleSizeChange (val) {
  253. this.size = val
  254. this.currpage = 1
  255. this.searchdata()
  256. },
  257. handleCurrentChange (val) {
  258. this.currpage = val
  259. this.searchdata()
  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. deleteinstrumentzl(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.searchdata()
  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. getOperaTpyelist () {
  309. // 获取样本单位
  310. let _this = this
  311. let params = {
  312. code: 'OperaTpye'
  313. }
  314. OperaTpyelist(params)
  315. .then(res => {
  316. _this.classificationlist = res.info
  317. })
  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.searchdata()
  328. },
  329. formatDateTime (date) {
  330. var y = date.getFullYear()
  331. var m = date.getMonth() + 1
  332. m = m < 10 ? '0' + m : m
  333. var d = date.getDate()
  334. d = d < 10 ? '0' + d : d
  335. // var h = date.getHours();
  336. // var minute = date.getMinutes();
  337. // minute = minute < 10 ? ('0' + minute) : minute;
  338. return y + '-' + m + '-' + d // + ' ' + h + ':' + minute;
  339. },
  340. clearSearch () {
  341. this.search.InstrumenCode = ''
  342. this.search.InstrumenName = ''
  343. this.search.OperaTpye = ''
  344. this.search.OperaUser = ''
  345. this.OperaOn = []
  346. this.searchdata()
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. .el-pagination {
  353. margin: 1rem 0 2rem;
  354. text-align: right;
  355. }
  356. .plab {
  357. font-size: 13px;
  358. color: #999;
  359. }
  360. </style>