maintenance.vue 16 KB

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