maintenance.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-button type="text" @click="backToDetection" icon="el-icon-back" class="back">返回</el-button>
  8. </el-form-item>
  9. <el-form-item class="divLine"></el-form-item>
  10. <el-form-item>{{mouldName}}</el-form-item>
  11. <el-form-item class="state" style="float: right;">当前状态:
  12. <span v-if="mouldState == 0">静止</span>
  13. <span v-else-if="mouldState == 1">运动</span>
  14. <span v-else-if="mouldState == 2">告警</span>
  15. <span v-else-if="mouldState == 3">待报废</span>
  16. <span v-else-if="mouldState == 4">已报废</span>
  17. </el-form-item>
  18. </el-form>
  19. </el-col>
  20. <!-- 模具处理 -->
  21. <el-col :span="24" class="title">模具处理</el-col>
  22. <el-col :span="6" style="line-height: 32px; border-right: #c3c3c3 1px solid;">
  23. 当前保养状态:
  24. <span v-if="requirement" style="color: #ff4949;">需要</span>
  25. <span v-else style="color: black;">正常</span>
  26. <el-button size="small" type="primary" @click="showMaintenance" style="margin-left: 16px;"
  27. v-if="!(user.parentId == 1 && user.subordinateType == 1) && requirement">立即处理
  28. </el-button>
  29. </el-col>
  30. <el-col :span="8" :offset="2" style="line-height: 32px;">
  31. 云模盒告警:{{warningInfo}}
  32. <el-button size="small" type="primary" @click="warningFormVisible = true" style="margin-left: 16px;"
  33. v-if="!(user.parentId == 1 && user.subordinateType == 1) && stage != 0">立即处理
  34. </el-button>
  35. </el-col>
  36. <!-- 操作记录 -->
  37. <el-col :span="24" class="title">处理记录</el-col>
  38. <!-- 列表 -->
  39. <el-table :data="records" highlight-current-row v-loading="listLoading" style="width: 100%;" :height="tableHeight">
  40. <el-table-column type="index" width="60"></el-table-column>
  41. <el-table-column prop="maintainUserName" label="保养人" width="100" sortable></el-table-column>
  42. <el-table-column prop="maintainType" label="保养方案" sortable></el-table-column>
  43. <el-table-column prop="fileName" label="保养照片" width="200" sortable>
  44. <template slot-scope="scope" v-if="scope.row.fileUrl != null">
  45. <a style="color: #409EFF; cursor: pointer; text-decoration: none;"
  46. :href="scope.row.fileUrl" :download="scope.row.fileName">
  47. <!-- 大图加载 -->
  48. <div class="demo-image__preview">
  49. <el-image style="width: 100px; height: 100px"
  50. :src="scope.row.fileUrl" :preview-src-list="scope.row.fileUrl"></el-image>
  51. </div>
  52. </a>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="indate" label="关闭时间" width="200" sortable></el-table-column>
  56. </el-table>
  57. <!--工具条-->
  58. <el-col :span="24" class="toolbar">
  59. <el-pagination
  60. @size-change="handleSizeChange"
  61. @current-change="handleCurrentChange"
  62. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  63. :page-size="20"
  64. layout="total, sizes, prev, pager, next"
  65. :total="total"
  66. style="float:right;"
  67. ></el-pagination>
  68. </el-col>
  69. <!--新增界面-->
  70. <el-dialog title="处理保养" v-if="maintenanceFormVisible" :visible.sync="maintenanceFormVisible" :close-on-click-modal="false" customClass="customWidth">
  71. <el-form :model="maintenanceForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
  72. <el-form-item label="保养类型" prop="type">
  73. <!-- 保养类型选择 -->
  74. <el-select v-model="type.value" filterable placeholder="请选择保养类型" style="width:202px">
  75. <el-option
  76. v-for="item in type"
  77. :key="item.value"
  78. :label="item.label"
  79. :value="item.value"
  80. ></el-option>
  81. </el-select>
  82. </el-form-item>
  83. <!-- 保养类型为1时 选择易损件ID -->
  84. <el-form-item v-if="type.value == 1" label="易损件" prop="vulnerable">
  85. <el-select
  86. v-model="vulnerable.value"
  87. clearable
  88. filterable
  89. placeholder="请选择易损件"
  90. style="width:202px"
  91. >
  92. <el-option
  93. v-for="item in vulnerable"
  94. :key="item.value"
  95. :label="item.label"
  96. :value="item.value"
  97. ></el-option>
  98. </el-select>
  99. </el-form-item>
  100. <!-- 保养类型为0时 选择保养动作 -->
  101. <el-form-item v-else label="动作" prop="action">
  102. <el-select v-model="action.value" filterable placeholder="请选择动作" style="width:202px">
  103. <el-option
  104. v-for="item in action"
  105. :key="item.value"
  106. :label="item.label"
  107. :value="item.value"
  108. ></el-option>
  109. </el-select>
  110. </el-form-item>
  111. <el-form-item label="保养照片">
  112. <el-upload ref="upload" action="customize" :http-request="maintain" :limit="1" :auto-upload="false" :before-upload="beforeUpload">
  113. <el-button size="small" type="primary">上传</el-button>
  114. </el-upload>
  115. </el-form-item>
  116. </el-form>
  117. <div slot="footer" class="dialog-footer">
  118. <el-button @click.native="maintenanceFormVisible = false">取消</el-button>
  119. <el-button type="primary" @click.native="maintainConfirm" :loading="maintenanceLoading">立即处理</el-button>
  120. </div>
  121. </el-dialog>
  122. <!--告警处理界面-->
  123. <el-dialog
  124. title="告警处理"
  125. v-if="warningFormVisible"
  126. :visible.sync="warningFormVisible"
  127. :close-on-click-modal="false"
  128. customClass="customWidth"
  129. >
  130. <el-form
  131. :model="warningForm"
  132. label-width="100px"
  133. :rules="formRules"
  134. ref="addForm"
  135. :inline="true"
  136. class="demo-form-inline"
  137. >
  138. <el-form-item label="告警类型">
  139. <el-input placeholder="请选择告警类型" v-model="warningInfo" :disabled="true"></el-input>
  140. </el-form-item>
  141. <el-form-item label="云模盒设置" prop="action">
  142. <el-select
  143. v-model="warningForm.equipmentId"
  144. filterable
  145. placeholder="请选择云模盒"
  146. style="width:202px"
  147. >
  148. <el-option
  149. v-for="item in equipments"
  150. :key="item.value"
  151. :label="item.label"
  152. :value="item.value"
  153. ></el-option>
  154. </el-select>
  155. </el-form-item>
  156. </el-form>
  157. <div slot="footer" class="dialog-footer">
  158. <el-button @click.native="warningFormVisible = false">取消</el-button>
  159. <el-button type="primary" @click.native="warningArrangement" :loading="warningLoading">立即处理</el-button>
  160. </div>
  161. </el-dialog>
  162. </section>
  163. </template>
  164. <script>
  165. import util from "../../common/js/util";
  166. export default {
  167. data() {
  168. return {
  169. user: JSON.parse(sessionStorage.getItem("user")),
  170. //本页模具ID
  171. mouldId: null,
  172. //模具名字
  173. mouldName: null,
  174. //模具状态
  175. mouldState: 0,
  176. options: [{ value: "aaa", label: "123" }, { value: "bbb", label: "456" }],
  177. //记录
  178. records: [],
  179. //警告信息
  180. warningInfo: "",
  181. stage: 0,
  182. //告警时需要更换的设备的列表
  183. equipments: [],
  184. //标题栏过滤器
  185. filters: {
  186. name: "",
  187. value: ""
  188. },
  189. listLoading: false,
  190. page: 1,
  191. size: 20,
  192. total: 0,
  193. tableHeight: 0,
  194. //活跃页面
  195. activePage: 0,
  196. formRules: {},
  197. //保养界面 种类
  198. type: [{ label: "动作", value: 0 }, { label: "易损件", value: 1 }],
  199. //保养界面 动作
  200. action: [{ label: "喷漆", value: 0 }, { label: "检查", value: 1 }],
  201. //易损件 假数据
  202. vulnerable: [],
  203. //是否需要保养 提示
  204. requirement: false,
  205. prompt: true,
  206. //保养详情界面显示
  207. maintenanceFormVisible: false,
  208. maintenanceLoading: false,
  209. //告警详情界面显示
  210. warningFormVisible: false,
  211. warningLoading: false,
  212. //保养详情界面数据
  213. maintenanceForm: {
  214. username: "",
  215. account: "",
  216. mobile: "",
  217. teamName: "",
  218. companyId: "",
  219. roleType: "",
  220. flag: 0
  221. },
  222. //告警处理截面数据
  223. warningForm: {
  224. mouldId: null,
  225. equipmentId: null
  226. },
  227. imageUrl: ""
  228. };
  229. },
  230. methods: {
  231. //分页
  232. handleCurrentChange(val) {
  233. this.page = val;
  234. this.getList();
  235. },
  236. handleSizeChange(val) {
  237. this.size = val;
  238. this.getList();
  239. },
  240. //标签页面切换时
  241. handleClick(tab, event) {
  242. this.activeTab = tab.name;
  243. //应该是取得对应的消息 目前还没写
  244. },
  245. selsChange: function(sels) {
  246. this.sels = sels;
  247. },
  248. backToDetection() {
  249. this.$router.go(-1);
  250. },
  251. //上传格式和大小限制
  252. beforeUpload(file) {
  253. const isJPG = file.type === "image/jpg";
  254. const isJPEG = file.type === "image/jpeg";
  255. const isPNG = file.type === "image/png";
  256. var rightType = isJPG || isPNG || isJPEG;
  257. const isLt5M = file.size / 1024 / 1024 < 5;
  258. if (!rightType) {
  259. this.$message.error("上传的图片只能是 JPG 或 PNG 格式!");
  260. }
  261. if (!isLt5M) {
  262. this.$message.error("上传的图片大小不能超过 5MB!");
  263. }
  264. return rightType && isLt5M;
  265. },
  266. //显示保养界面
  267. showMaintenance: function() {
  268. this.maintenanceFormVisible = true;
  269. },
  270. //获取记录
  271. getList() {
  272. this.listLoading = true;
  273. this.http.post(
  274. this.port.mold.moldMaintainList,
  275. { mouldId: this.mouldId, pageSize: this.size, pageNum: this.page },
  276. res => {
  277. this.listLoading = false;
  278. if (res.code == "ok") {
  279. this.records = res.data.list;
  280. this.total = res.data.total;
  281. } else {
  282. this.$message({
  283. message: res.msg,
  284. type: "error"
  285. });
  286. }
  287. },
  288. error => {
  289. this.listLoading = false;
  290. this.$message({
  291. message: error,
  292. type: "error"
  293. });
  294. }
  295. );
  296. },
  297. //模具详情 获取模具名字用的
  298. getDetail() {
  299. this.http.post(
  300. this.port.mold.moldDetail,
  301. {
  302. id: this.mouldId
  303. },
  304. res => {
  305. if (res.code == "ok") {
  306. this.mouldName = res.data.vo.modelName;
  307. this.mouldState = res.data.vo.state;
  308. this.requirement = res.data.vo.isMaintain == 1;
  309. this.stage = res.data.vo.stage;
  310. if(this.stage == 0){
  311. this.warningInfo = "正常";
  312. }else if(this.stage == 1){
  313. this.warningInfo = "温度过高";
  314. }else if(this.stage == 2){
  315. this.warningInfo = "电量过低";
  316. }else if(this.stage == 3){
  317. this.warningInfo = "温度过高、电量过低";
  318. }else{
  319. this.warningInfo = "状况不明";
  320. }
  321. } else {
  322. this.$message({
  323. message: res.msg,
  324. type: "error"
  325. });
  326. }
  327. },
  328. error => {
  329. this.$message({
  330. message: error,
  331. type: "error"
  332. });
  333. }
  334. );
  335. },
  336. //模具保养的按钮按下之后(关闭之后也要清理文件但是还没写)
  337. maintainConfirm() {
  338. if (this.$refs.upload.uploadFiles.length == 1) {
  339. this.$refs.upload.submit();
  340. } else {
  341. this.$message({
  342. message: "必须上传照片",
  343. type: "error"
  344. });
  345. }
  346. },
  347. //模具保养
  348. maintain(params) {
  349. if (this.type.value != null) {
  350. var fileObj = params.file;
  351. var form = new FormData();
  352. form.append("file", fileObj);
  353. form.append("mouldId", this.mouldId);
  354. form.append("maintainType", this.type.value);
  355. if (this.type.value == 0) {
  356. if (this.action.value == null) {
  357. return;
  358. }
  359. form.append("ways", this.action.value);
  360. } else {
  361. if (this.vulnerable.value == null) {
  362. return;
  363. }
  364. form.append("ways", this.vulnerable.value); //后面应该换成易损件的ID
  365. }
  366. this.http.uploadFile(
  367. this.port.mold.moldMaintain,
  368. form,
  369. res => {
  370. if (res.code == "ok") {
  371. this.$message({
  372. message: "保养完成",
  373. type: "success"
  374. });
  375. this.maintenanceFormVisible = false;
  376. this.requirement = false;
  377. this.$refs.upload.clearFiles();
  378. this.getList();
  379. } else {
  380. this.$message({
  381. message: res.msg,
  382. type: "error"
  383. });
  384. }
  385. },
  386. error => {
  387. this.listLoading = false;
  388. this.$message({
  389. message: error,
  390. type: "error"
  391. });
  392. }
  393. );
  394. }
  395. },
  396. //获取告警时可以更换的设备列表
  397. getAlternativeEquipment() {
  398. this.http.post(
  399. this.port.mold.moldChangeRequirement,
  400. {
  401. mouldId: this.mouldId
  402. },
  403. res => {
  404. if (res.code == "ok") {
  405. this.equipments = [];
  406. res.data.forEach(item => {
  407. this.equipments.push({ label: item.equipmentNo, value: item.id });
  408. });
  409. } else {
  410. this.$message({
  411. message: res.msg,
  412. type: "error"
  413. });
  414. }
  415. },
  416. error => {
  417. this.$message({
  418. message: error,
  419. type: "error"
  420. });
  421. }
  422. );
  423. },
  424. //告警处理
  425. warningArrangement() {
  426. if (this.warningForm.equipmentId == null) {
  427. this.$message({
  428. message: "请选择云模盒",
  429. type: "error"
  430. });
  431. } else {
  432. this.http.post(
  433. this.port.mold.moldChange,
  434. this.warningForm,
  435. res => {
  436. if (res.code == "ok") {
  437. this.$message({
  438. message: "告警处理完毕",
  439. type: "success"
  440. });
  441. this.warningFormVisible = false;
  442. } else {
  443. this.$message({
  444. message: res.msg,
  445. type: "error"
  446. });
  447. }
  448. },
  449. error => {
  450. this.$message({
  451. message: error,
  452. type: "error"
  453. });
  454. }
  455. );
  456. }
  457. }
  458. },
  459. created() {
  460. let height = window.innerHeight;
  461. this.tableHeight = height - 370;
  462. },
  463. mounted() {
  464. this.mouldId = this.$route.params.id; //传到当前页面的模具编号
  465. this.warningForm.mouldId = this.mouldId; //顺便把相关的告警中的模具ID赋值一下
  466. this.getList();
  467. this.getDetail();
  468. this.getAlternativeEquipment();
  469. }
  470. };
  471. </script>
  472. <style scoped>
  473. .title {
  474. padding-left: 10px;
  475. padding-bottom: 0px;
  476. margin: 20px 0;
  477. font-size: 16px;
  478. line-height: 24px;
  479. border-left: 1px #20a0ff solid;
  480. }
  481. .toolbar .el-form-item {
  482. font-size: 14px;
  483. vertical-align: middle;
  484. }
  485. .back {
  486. font-size: 16px;
  487. }
  488. .divLine {
  489. width: 2px;
  490. background: #c3c3c3;
  491. height: 100%;
  492. }
  493. .projectTitle {
  494. font-size: 18px;
  495. color: #333;
  496. }
  497. </style>