maintenance.vue 12 KB

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