index.vue 12KB

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