maintenance.vue 13 KB

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