index.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button
  6. class="filter-item"
  7. style="float:right;"
  8. type="primary"
  9. icon="el-icon-circle-plus-outline"
  10. size="small"
  11. @click="AddManage()"
  12. >新增</el-button
  13. >
  14. </div>
  15. <div class="app-container">
  16. <div class="cell clearfix">
  17. <el-input
  18. style="width: 400px;"
  19. v-model.trim="listQuery.searchKey"
  20. class="filter-item"
  21. placeholder="输入序列号/设备名/设备类型搜索"
  22. size="small"
  23. @keyup.enter.native='seahcerMacherInfo'
  24. />
  25. <el-button
  26. class="filter-item"
  27. type="primary"
  28. icon="el-icon-search"
  29. size="small"
  30. @click="seahcerMacherInfo()"
  31. >搜索</el-button
  32. >
  33. <!-- <el-button
  34. class="filter-item"
  35. type="primary"
  36. icon="el-icon-search"
  37. size="small"
  38. @click="Auto()"
  39. >脚本</el-button
  40. > -->
  41. </div>
  42. <div class="cell clearfix">
  43. <label class="title">
  44. <span class="name">分区:</span>
  45. </label>
  46. <div class="time">
  47. <ul class>
  48. <li
  49. :class="item.id == schedulType ? 'active' : ''"
  50. v-for="item in this.zones"
  51. :key="item.id"
  52. @click="selectSchedulType(item.id)"
  53. >
  54. {{ item.name }}
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. <div class="cell clearfix">
  60. <label class="title">
  61. <span class="name">设备类型:</span>
  62. </label>
  63. <div class="time">
  64. <ul class>
  65. <li
  66. :class="item.id == schedulTypeone ? 'active' : ''"
  67. v-for="item in this.DeviceType"
  68. :key="item.id"
  69. @click="selectSchedulTypeOne(item.id)"
  70. >
  71. {{ item.name }}
  72. </li>
  73. </ul>
  74. </div>
  75. </div>
  76. <div class="cell clearfix">
  77. <label class="title">
  78. <span class="name">状态:</span>
  79. </label>
  80. <div class="time">
  81. <ul class>
  82. <li
  83. :class="item.id == schedulTypetwo ? 'active' : ''"
  84. v-for="item in this.AllStatus"
  85. :key="item.id"
  86. @click="selectSchedulTypeTwo(item.id)"
  87. >
  88. {{ item.name }}
  89. </li>
  90. </ul>
  91. </div>
  92. </div>
  93. <el-table
  94. :data="tableData"
  95. border
  96. style="width: 100%"
  97. :row-style="{ color: '#303133' }"
  98. :header-cell-style="{
  99. backgroundColor: 'rgb(245, 247, 250)',
  100. color: '#606266'
  101. }"
  102. >
  103. <el-table-column label="序号" width="80" align="center" type="index">
  104. <!-- <template slot-scope="scope">{{ scope.row.id }}</template> -->
  105. </el-table-column>
  106. <el-table-column label="序列号" width="120" align="center">
  107. <template slot-scope="scope">{{ scope.row.serial_number }}</template>
  108. </el-table-column>
  109. <el-table-column label="设备类型" width="120" align="center">
  110. <template slot-scope="scope">{{ scope.row.device_type }}</template>
  111. </el-table-column>
  112. <el-table-column label="设备名称" width="120" align="center">
  113. <template slot-scope="scope">{{ scope.row.device_name }}</template>
  114. </el-table-column>
  115. <el-table-column label="设备型号" width="120" align="center">
  116. <template slot-scope="scope">{{ scope.row.device_mode }}</template>
  117. </el-table-column>
  118. <el-table-column label="分区" align="center">
  119. <template slot-scope="scope">
  120. <span v-if="scope.row.device_type!='水处理机'"> {{ scope.row.name }}</span>
  121. <span v-if="scope.row.device_type=='水处理机'"> {{getZoneName(scope.row.zone_id) }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="机位号" align="center">
  125. <template slot-scope="scope">{{ scope.row.bed_number }}</template>
  126. </el-table-column>
  127. <el-table-column label="机器状态" align="center">
  128. <template slot-scope="scope">{{ scope.row.machine_status }}</template>
  129. </el-table-column>
  130. <el-table-column label="使用次数" align="center" v-if="org_id!=0&&org_id!=10440">
  131. <template slot-scope="scope">{{getTotal(scope.row.bed_id,scope.row.user_total) }}</template>
  132. </el-table-column>
  133. <el-table-column label="操作" width="200" align="center">
  134. <template slot-scope="scope">
  135. <el-button
  136. @click="handleClick(scope.row.id, scope.$index, scope.row.bed_id)"
  137. type="primary"
  138. size="small"
  139. >查看</el-button>
  140. <el-button
  141. @click="deleManageMent(scope.row.id,scope.row.equiment_id,scope.$index)"
  142. size="small"
  143. type="danger"
  144. icon="el-icon-delete"
  145. >删除</el-button>
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <el-pagination
  150. @size-change="handleSizeChange"
  151. @current-change="handleCurrentChange"
  152. :page-sizes="[10, 20, 50, 100]"
  153. :page-size="10"
  154. background
  155. style="margin-top:20px;float: right"
  156. layout="total, sizes, prev, pager, next, jumper"
  157. :total="total"
  158. ></el-pagination>
  159. <!-- 新增设备 -->
  160. <manage-form
  161. ref="manageForm"
  162. v-on:getAllMachineInfo="getAllMachineInfo"
  163. ></manage-form>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import BreadCrumb from "../components/bread-crumb";
  169. import { getAllMachineInfo, getAllSubregion,getUserMachTotalCount,deleteManageMent,getInformationManaList } from "@/api/manage";
  170. import ManageForm from "./components/ManageForm";
  171. export default {
  172. name: "index.vue",
  173. components: {
  174. BreadCrumb,
  175. ManageForm
  176. },
  177. data() {
  178. return {
  179. crumbs: [
  180. { path: false, name: "设备管理" },
  181. { path: false, name: "设备管理" }
  182. ],
  183. searchKey: "",
  184. zones: [{ id: 0, name: "全部" }],
  185. schedulType: 0,
  186. schedulTypeone: 0,
  187. schedulTypetwo: 0,
  188. DeviceType: [
  189. { id: 0, name: "全部" },
  190. { id: 1, name: "透析机" },
  191. { id: 2, name: "水处理机" },
  192. { id: 3, name: "其他" }
  193. ],
  194. AllStatus: [
  195. { id: 0, name: "全部" },
  196. { id: 1, name: "使用机" },
  197. { id: 2, name: "备用机" },
  198. { id: 3, name: "急诊机" },
  199. { id: 4, name: "报废机" }
  200. ],
  201. tableData: [],
  202. listQuery: {
  203. page: 1,
  204. limit: 10,
  205. searchKey: "",
  206. zoneid: "",
  207. equipmentid: "",
  208. statusid: ""
  209. },
  210. total: 0,
  211. count:[],
  212. org_id:0,
  213. };
  214. },
  215. methods: {
  216. getAllSubregion() {
  217. getAllSubregion().then(response => {
  218. if (response.data.state === 1) {
  219. var zone = response.data.data.zones;
  220. var zones = [{ id: 0, name: "全部" }];
  221. for (let i = 0; i < zone.length; i++) {
  222. const item = zone[i];
  223. zones.push({ id: item.id, name: item.name });
  224. }
  225. // console.log('zones', zones)
  226. this.zones = zones;
  227. }
  228. });
  229. },
  230. selectSchedulType(scheduleType) {
  231. this.schedulType = scheduleType;
  232. this.listQuery.zoneid = scheduleType;
  233. this.getAllMachineInfo();
  234. },
  235. selectSchedulTypeOne(scheduleType) {
  236. this.schedulTypeone = scheduleType;
  237. this.listQuery.equipmentid = scheduleType;
  238. this.getAllMachineInfo();
  239. },
  240. selectSchedulTypeTwo(scheduleType) {
  241. this.schedulTypetwo = scheduleType;
  242. this.listQuery.statusid = scheduleType;
  243. this.getAllMachineInfo();
  244. },
  245. seahcerMacherInfo() {
  246. this.getAllMachineInfo();
  247. },
  248. AddManage() {
  249. this.$refs.manageForm.open();
  250. },
  251. getAllMachineInfo() {
  252. getAllMachineInfo(
  253. this.listQuery.page,
  254. this.listQuery.limit,
  255. this.listQuery.searchKey,
  256. this.listQuery.zoneid,
  257. this.listQuery.equipmentid,
  258. this.listQuery.statusid
  259. ).then(response => {
  260. if (response.data.state === 1) {
  261. var addmahcer = response.data.data.addmahcer;
  262. // console.log("addmacher", addmahcer);
  263. for (let index = 0; index < addmahcer.length; index++) {
  264. if (addmahcer[index].device_type === 1) {
  265. addmahcer[index].device_type = "透析机";
  266. addmahcer[index].bed_number = addmahcer[index].number;
  267. }
  268. if (addmahcer[index].device_type === 2) {
  269. addmahcer[index].device_type = "水处理机";
  270. addmahcer[index].bed_number = addmahcer[index].bed_number;
  271. }
  272. if (addmahcer[index].device_type === 3) {
  273. addmahcer[index].device_type = "其他";
  274. addmahcer[index].bed_number = addmahcer[index].bed_number;
  275. }
  276. if (addmahcer[index].machine_status === 1) {
  277. addmahcer[index].machine_status = "使用机";
  278. }
  279. if (addmahcer[index].machine_status === 2) {
  280. addmahcer[index].machine_status = "备用机";
  281. }
  282. if (addmahcer[index].machine_status === 3) {
  283. addmahcer[index].machine_status = "急诊机";
  284. }
  285. if (addmahcer[index].machine_status === 4) {
  286. addmahcer[index].machine_status = "报废机";
  287. }
  288. }
  289. this.tableData = addmahcer;
  290. console.log('addmacher', addmahcer)
  291. var total = response.data.data.total;
  292. // console.log('total', total)
  293. this.total = total;
  294. }
  295. });
  296. },
  297. handleSizeChange(limit) {
  298. this.listQuery.limit = limit;
  299. this.getAllMachineInfo();
  300. },
  301. handleCurrentChange(page) {
  302. this.listQuery.page = page;
  303. this.getAllMachineInfo();
  304. },
  305. handleClick(id, index, bedid) {
  306. this.$router.push({
  307. path:
  308. "/device/home?index=" +
  309. index +
  310. "&" +
  311. "bedid=" +
  312. bedid +
  313. "&" +
  314. "id=" +
  315. id
  316. });
  317. // this.$router.push({ path: '/device/home?index=' + index + '&' + 'id=' + id })
  318. },
  319. getUserMachTotalCount(){
  320. getUserMachTotalCount().then(response=>{
  321. if(response.data.state == 1){
  322. var count = response.data.data.count
  323. // console.log("count",count)
  324. this.count = count
  325. }
  326. })
  327. },
  328. getTotal(id,usertotal){
  329. if(usertotal == ''){
  330. usertotal = 0
  331. }
  332. var count = 0
  333. for(let i=0;i<this.count.length;i++){
  334. if(id == this.count[i].bed_number){
  335. count = parseInt(this.count[i].Total)+parseInt(usertotal)
  336. }
  337. }
  338. // console.log("count",count)
  339. return count
  340. },
  341. deleManageMent(id,equimentid){
  342. if(equimentid != 0){
  343. this.$confirm(
  344. '该设备已有使用记录,确认要删除吗? <br>删除后,信息将无法恢复',
  345. '删除提示',
  346. {
  347. dangerouslyUseHTMLString: true,
  348. confirmButtonText: '确定',
  349. cancelButtonText: '取消',
  350. type: 'warning'
  351. }
  352. ).then(() => {
  353. deleteManageMent(id).then(response => {
  354. // eslint-disable-next-line eqeqeq
  355. if (response.data.state == 1) {
  356. var msg = response.data.data.msg
  357. this.getAllMachineInfo()
  358. this.$message.success("删除成功")
  359. } else {
  360. this.$message.error('删除失败')
  361. }
  362. }).catch(e => {})
  363. }).catch(() => {
  364. return false
  365. })
  366. }
  367. if(equimentid ==0){
  368. this.$confirm(
  369. '确认要删除所选设备吗? <br>删除后,信息将无法恢复',
  370. '删除提示',
  371. {
  372. dangerouslyUseHTMLString: true,
  373. confirmButtonText: '确定',
  374. cancelButtonText: '取消',
  375. type: 'warning'
  376. }
  377. ).then(() => {
  378. deleteManageMent(id).then(response => {
  379. // eslint-disable-next-line eqeqeq
  380. if (response.data.state == 1) {
  381. var msg = response.data.data.msg
  382. this.getAllMachineInfo()
  383. this.$message.success('删除成功')
  384. } else {
  385. this.$message.error('删除失败')
  386. }
  387. }).catch(e => {})
  388. }).catch(() => {
  389. return false
  390. })
  391. }
  392. },
  393. Auto(){
  394. getInformationManaList().then(response=>{
  395. if(response.data.state == 1){
  396. var list = response.data.data.list
  397. this.$message.success("保存成功!")
  398. }
  399. })
  400. },
  401. getZoneName(val){
  402. var zone_name= ""
  403. for(let i=0;i<this.zones.length;i++){
  404. if(val == this.zones[i].id){
  405. zone_name = this.zones[i].name
  406. }
  407. }
  408. return zone_name
  409. }
  410. },
  411. created() {
  412. // 获取所有的分区
  413. this.getAllSubregion();
  414. this.getAllMachineInfo();
  415. this.getUserMachTotalCount()
  416. this.org_id = this.$store.getters.xt_user.template_info.org_id
  417. }
  418. };
  419. </script>
  420. <style scoped></style>