maintenance.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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="warningArrangement = 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. { value: 1, label: "临时设备1" },
  189. { value: 2, label: "临时设备2" },
  190. { value: 3, label: "临时设备3" }
  191. ],
  192. //标题栏过滤器
  193. filters: {
  194. name: "",
  195. value: ""
  196. },
  197. listLoading: false,
  198. page: 1,
  199. size: 20,
  200. total: 0,
  201. tableHeight: 0,
  202. //活跃页面
  203. activePage: 0,
  204. formRules: {},
  205. //保养界面 种类
  206. type: [{ label: "动作", value: 0 }, { label: "易损件", value: 1 }],
  207. //保养界面 动作
  208. action: [{ label: "喷漆", value: 0 }, { label: "检查", value: 1 }],
  209. //易损件 假数据
  210. vulnerable: [
  211. { label: "易损件1", value: 0 },
  212. { label: "易损件12450", value: 1 },
  213. { label: "易损件114514", value: 2 }
  214. ],
  215. //是否需要保养 提示
  216. requirement: false,
  217. prompt: true,
  218. //保养详情界面显示
  219. maintenanceFormVisible: false,
  220. maintenanceLoading: false,
  221. //告警详情界面显示
  222. warningFormVisible: false,
  223. warningLoading: false,
  224. //保养详情界面数据
  225. maintenanceForm: {
  226. username: "",
  227. account: "",
  228. mobile: "",
  229. teamName: "",
  230. companyId: "",
  231. roleType: "",
  232. flag: 0
  233. },
  234. //告警处理截面数据
  235. warningForm: {
  236. mouldId: null,
  237. equipmentId: null
  238. },
  239. imageUrl: ""
  240. };
  241. },
  242. methods: {
  243. //分页
  244. handleCurrentChange(val) {
  245. this.page = val;
  246. this.getList();
  247. },
  248. handleSizeChange(val) {
  249. this.size = val;
  250. this.getList();
  251. },
  252. //标签页面切换时
  253. handleClick(tab, event) {
  254. this.activeTab = tab.name;
  255. //应该是取得对应的消息 目前还没写
  256. },
  257. selsChange: function(sels) {
  258. this.sels = sels;
  259. },
  260. backToDetection() {
  261. this.$router.go(-1);
  262. },
  263. //上传格式和大小限制
  264. beforeUpload(file) {
  265. const isJPG = file.type === "image/jpg";
  266. const isJPEG = file.type === "image/jpeg";
  267. const isPNG = file.type === "image/png";
  268. var rightType = isJPG || isPNG || isJPEG;
  269. const isLt5M = file.size / 1024 / 1024 < 5;
  270. if (!rightType) {
  271. this.$message.error("上传的图片只能是 JPG 或 PNG 格式!");
  272. }
  273. if (!isLt5M) {
  274. this.$message.error("上传的图片大小不能超过 5MB!");
  275. }
  276. return rightType && isLt5M;
  277. },
  278. //显示保养界面
  279. showMaintenance: function() {
  280. this.maintenanceFormVisible = true;
  281. },
  282. //获取记录
  283. getList() {
  284. this.listLoading = true;
  285. this.http.post(
  286. this.port.mold.moldMaintainList,
  287. { mouldId: this.mouldId, pageSize: this.size, pageNum: this.page },
  288. res => {
  289. this.listLoading = false;
  290. if (res.code == "ok") {
  291. this.records = res.data.list;
  292. this.total = res.data.total;
  293. } else {
  294. this.$message({
  295. message: res.msg,
  296. type: "error"
  297. });
  298. }
  299. },
  300. error => {
  301. this.listLoading = false;
  302. this.$message({
  303. message: error,
  304. type: "error"
  305. });
  306. }
  307. );
  308. },
  309. //模具详情 获取模具名字用的
  310. getDetail() {
  311. this.http.post(
  312. this.port.mold.moldDetail,
  313. {
  314. id: this.mouldId
  315. },
  316. res => {
  317. if (res.code == "ok") {
  318. this.mouldName = res.data.vo.modelName;
  319. this.mouldState = res.data.vo.state;
  320. this.requirement = res.data.vo.isMaintain == 1;
  321. this.stage = res.data.vo.stage;
  322. if(this.stage == 0){
  323. this.warningInfo = "正常";
  324. }else if(this.stage == 1){
  325. this.warningInfo = "温度过高";
  326. }else if(this.stage == 2){
  327. this.warningInfo = "电量过低";
  328. }else if(this.stage == 3){
  329. this.warningInfo = "温度过高、电量过低";
  330. }else{
  331. this.warningInfo = "状况不明";
  332. }
  333. } else {
  334. this.$message({
  335. message: res.msg,
  336. type: "error"
  337. });
  338. }
  339. },
  340. error => {
  341. this.$message({
  342. message: error,
  343. type: "error"
  344. });
  345. }
  346. );
  347. },
  348. //模具保养的按钮按下之后(关闭之后也要清理文件但是还没写)
  349. maintainConfirm() {
  350. if (this.$refs.upload.uploadFiles.length == 1) {
  351. this.$refs.upload.submit();
  352. } else {
  353. this.$message({
  354. message: "必须上传照片",
  355. type: "error"
  356. });
  357. }
  358. },
  359. //模具保养
  360. maintain(params) {
  361. if (this.type.value != null) {
  362. var fileObj = params.file;
  363. var form = new FormData();
  364. form.append("file", fileObj);
  365. form.append("mouldId", this.mouldId);
  366. form.append("maintainType", this.type.value);
  367. if (this.type.value == 0) {
  368. if (this.action.value == null) {
  369. return;
  370. }
  371. form.append("ways", this.action.value);
  372. } else {
  373. if (this.vulnerable.value == null) {
  374. return;
  375. }
  376. form.append("ways", this.vulnerable.value); //后面应该换成易损件的ID
  377. }
  378. this.http.uploadFile(
  379. this.port.mold.moldMaintain,
  380. form,
  381. res => {
  382. if (res.code == "ok") {
  383. this.$message({
  384. message: "保养完成",
  385. type: "success"
  386. });
  387. this.maintenanceFormVisible = false;
  388. this.requirement = false;
  389. this.$refs.upload.clearFiles();
  390. this.getList();
  391. } else {
  392. this.$message({
  393. message: res.msg,
  394. type: "error"
  395. });
  396. }
  397. },
  398. error => {
  399. this.listLoading = false;
  400. this.$message({
  401. message: error,
  402. type: "error"
  403. });
  404. }
  405. );
  406. }
  407. },
  408. //获取告警时可以更换的设备列表
  409. getAlternativeEquipment() {
  410. this.http.post(
  411. this.port.mold.moldChangeRequirement,
  412. {
  413. mouldId: this.mouldId
  414. },
  415. res => {
  416. if (res.code == "ok") {
  417. this.equipments = [];
  418. res.data.forEach(item => {
  419. this.equipments.push({ label: item.equipmentNo, value: item.id });
  420. });
  421. } else {
  422. this.$message({
  423. message: res.msg,
  424. type: "error"
  425. });
  426. }
  427. },
  428. error => {
  429. this.$message({
  430. message: error,
  431. type: "error"
  432. });
  433. }
  434. );
  435. },
  436. //告警处理
  437. warningArrangement() {
  438. if (this.warningForm.equipmentId == null) {
  439. this.$message({
  440. message: "请选择云模盒",
  441. type: "error"
  442. });
  443. } else {
  444. this.http.post(
  445. this.port.mold.moldChange,
  446. this.warningForm,
  447. res => {
  448. if (res.code == "ok") {
  449. this.$message({
  450. message: "告警处理完毕",
  451. type: "success"
  452. });
  453. this.warningFormVisible = false;
  454. } else {
  455. this.$message({
  456. message: res.msg,
  457. type: "error"
  458. });
  459. }
  460. },
  461. error => {
  462. this.$message({
  463. message: error,
  464. type: "error"
  465. });
  466. }
  467. );
  468. }
  469. }
  470. },
  471. created() {
  472. let height = window.innerHeight;
  473. this.tableHeight = height - 370;
  474. },
  475. mounted() {
  476. this.mouldId = this.$route.params.id; //传到当前页面的模具编号
  477. this.warningForm.mouldId = this.mouldId; //顺便把相关的告警中的模具ID赋值一下
  478. this.getList();
  479. this.getDetail();
  480. this.getAlternativeEquipment();
  481. }
  482. };
  483. </script>
  484. <style scoped>
  485. .title {
  486. padding-left: 10px;
  487. padding-bottom: 0px;
  488. margin: 20px 0;
  489. font-size: 16px;
  490. line-height: 24px;
  491. border-left: 1px #20a0ff solid;
  492. }
  493. .toolbar .el-form-item {
  494. font-size: 14px;
  495. vertical-align: middle;
  496. }
  497. .back {
  498. font-size: 16px;
  499. }
  500. .divLine {
  501. width: 2px;
  502. background: #c3c3c3;
  503. height: 100%;
  504. }
  505. .projectTitle {
  506. font-size: 18px;
  507. color: #333;
  508. }
  509. </style>