maintenance.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 style="float: right">
  16. 当前保养状态:
  17. <span style="color: #ff4949; margin-right: 16px;">需要</span>
  18. <el-button size="small" type="primary" v-if="requirement" @click="showMaintenance">立即处理</el-button>
  19. </el-form-item>
  20. </el-form>
  21. </el-col>
  22. <!--列表-->
  23. <el-table
  24. :data="records"
  25. highlight-current-row
  26. :height="tableHeight"
  27. v-loading="listLoading"
  28. style="width: 100%;"
  29. >
  30. <el-table-column type="index" width="60"></el-table-column>
  31. <el-table-column prop="maintainUserName" label="保养人" width="100" sortable></el-table-column>
  32. <el-table-column prop="maintainType" label="保养方案" sortable></el-table-column>
  33. <el-table-column prop="fileName" label="保养照片" width="200" sortable></el-table-column>
  34. <el-table-column prop="indate" label="关闭时间" width="200" sortable></el-table-column>
  35. </el-table>
  36. <!--工具条-->
  37. <el-col :span="24" class="toolbar">
  38. <el-pagination
  39. @size-change="handleSizeChange"
  40. @current-change="handleCurrentChange"
  41. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  42. :page-size="20"
  43. layout="total, sizes, prev, pager, next"
  44. :total="total"
  45. style="float:right;"
  46. ></el-pagination>
  47. </el-col>
  48. <!--新增界面-->
  49. <el-dialog
  50. title="处理保养"
  51. v-if="maintenanceFormVisible"
  52. :visible.sync="maintenanceFormVisible"
  53. :close-on-click-modal="false"
  54. customClass="customWidth"
  55. >
  56. <el-form
  57. :model="maintenanceForm"
  58. label-width="100px"
  59. :rules="formRules"
  60. ref="addForm"
  61. :inline="true"
  62. class="demo-form-inline"
  63. >
  64. <el-form-item label="保养类型" prop="type">
  65. <!-- 保养类型选择 -->
  66. <el-select v-model="type.value" filterable placeholder="请选择保养类型" style="width:202px">
  67. <el-option
  68. v-for="item in type"
  69. :key="item.value"
  70. :label="item.label"
  71. :value="item.value"
  72. ></el-option>
  73. </el-select>
  74. </el-form-item>
  75. <!-- 保养类型为1时 选择易损件ID -->
  76. <el-form-item v-if="type.value == 1" label="选择易损件" prop="vulnerable">
  77. <el-select
  78. v-model="vulnerable.value"
  79. clearable
  80. filterable
  81. placeholder="请选择易损件"
  82. style="width:202px"
  83. >
  84. <el-option
  85. v-for="item in vulnerable"
  86. :key="item.value"
  87. :label="item.label"
  88. :value="item.value"
  89. ></el-option>
  90. </el-select>
  91. </el-form-item>
  92. <!-- 保养类型为0时 选择保养动作 -->
  93. <el-form-item v-else label="选择动作" prop="action">
  94. <el-select
  95. v-model="action.value"
  96. filterable
  97. placeholder="请选择动作"
  98. style="width:202px"
  99. >
  100. <el-option
  101. v-for="item in action"
  102. :key="item.value"
  103. :label="item.label"
  104. :value="item.value"
  105. ></el-option>
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item label="选择照片">
  109. <el-upload
  110. ref="upload"
  111. action="customize"
  112. :http-request="maintain"
  113. :limit="1"
  114. :auto-upload="false"
  115. >
  116. <el-button size="small" type="primary">上传</el-button>
  117. </el-upload>
  118. </el-form-item>
  119. </el-form>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button @click.native="maintenanceFormVisible = false">取消</el-button>
  122. <el-button type="primary" @click.native="maintainConfirm" :loading="maintenanceLoading">立即处理</el-button>
  123. </div>
  124. </el-dialog>
  125. </section>
  126. </template>
  127. <script>
  128. import util from "../../common/js/util";
  129. export default {
  130. data() {
  131. return {
  132. //本页模具ID
  133. mouldId: null,
  134. //模具名字
  135. mouldName: null,
  136. options: [{ value: "aaa", label: "123" }, { value: "bbb", label: "456" }],
  137. //记录
  138. records: [],
  139. //标题栏过滤器
  140. filters: {
  141. name: "",
  142. value: ""
  143. },
  144. listLoading: false,
  145. page: 1,
  146. size: 20,
  147. total: 0,
  148. tableHeight: 0,
  149. formRules: {},
  150. //保养界面 种类
  151. type: [{ label: "动作", value: 0 }, { label: "易损件", value: 1 }],
  152. //保养界面 动作
  153. action: [{ label: "喷漆", value: 0 }, { label: "检查", value: 1 }],
  154. //易损件
  155. vulnerable: [
  156. { label: "易损件1", value: 0 },
  157. { label: "易损件12450", value: 1 },
  158. { label: "易损件114514", value: 2 }
  159. ],
  160. //是否需要保养 提示
  161. requirement: true,
  162. prompt: true,
  163. //保养详情界面显示
  164. maintenanceFormVisible: false,
  165. maintenanceLoading: false,
  166. //保养详情界面数据
  167. maintenanceForm: {
  168. username: "",
  169. account: "",
  170. mobile: "",
  171. teamName: "",
  172. companyId: "",
  173. roleType: "",
  174. flag: 0
  175. },
  176. imageUrl: ""
  177. };
  178. },
  179. methods: {
  180. //分页
  181. handleCurrentChange(val) {
  182. this.page = val;
  183. this.getList();
  184. },
  185. handleSizeChange(val) {
  186. this.size = val;
  187. this.getList();
  188. },
  189. selsChange: function(sels) {
  190. this.sels = sels;
  191. },
  192. backToDetection() {
  193. this.$router.go(-1);
  194. },
  195. beforeUpload(file) {
  196. const isJPG = file.type === "image/png";
  197. const isLt2M = file.size / 1024 / 1024 < 2;
  198. if (!isJPG) {
  199. this.$message.error("上传头像图片只能是 PNG 格式!");
  200. }
  201. if (!isLt2M) {
  202. this.$message.error("上传头像图片大小不能超过 2MB!");
  203. }
  204. return isJPG && isLt2M;
  205. },
  206. //显示新增界面
  207. showMaintenance: function() {
  208. this.maintenanceFormVisible = true;
  209. },
  210. //获取记录
  211. getList() {
  212. this.listLoading = true;
  213. this.http.post(
  214. this.port.mold.moldMaintainList,
  215. { mouldId: this.mouldId, pageSize: this.size, pageNum: this.page },
  216. res => {
  217. this.listLoading = false;
  218. if (res.code == "ok") {
  219. this.records = res.data.list;
  220. } else {
  221. this.$message({
  222. message: res.msg,
  223. type: "error"
  224. });
  225. }
  226. },
  227. error => {
  228. this.listLoading = false;
  229. this.$message({
  230. message: error,
  231. type: "error"
  232. });
  233. }
  234. );
  235. },
  236. //模具详情 获取模具名字用的
  237. getDetail() {
  238. this.http.post(
  239. this.port.mold.moldDetail,
  240. {
  241. id: this.mouldId
  242. },
  243. res => {
  244. if (res.code == "ok") {
  245. this.mouldName = res.data.vo.modelName;
  246. } else {
  247. this.$message({
  248. message: res.msg,
  249. type: "error"
  250. });
  251. }
  252. },
  253. error => {
  254. this.$message({
  255. message: error,
  256. type: "error"
  257. });
  258. }
  259. );
  260. },
  261. //模具保养的按钮按下之后(关闭之后也要清理文件但是还没写)
  262. maintainConfirm() {
  263. if (this.$refs.upload.uploadFiles.length == 1) {
  264. this.$refs.upload.submit();
  265. this.$refs.upload.clearFiles();
  266. } else {
  267. this.$message({
  268. message: "必须上传照片",
  269. type: "error"
  270. });
  271. }
  272. },
  273. //模具保养
  274. maintain(params) {
  275. var fileObj = params.file;
  276. var form = new FormData();
  277. form.append("file", fileObj);
  278. form.append("mouldId", this.mouldId);
  279. form.append("maintainType", this.type.value);
  280. if (this.type.value == 0) {
  281. form.append("ways", this.action.value);
  282. } else {
  283. form.append("ways", this.vulnerable.value); //后面应该换成易损件的ID
  284. }
  285. this.http.uploadFile(
  286. this.port.mold.moldMaintain,
  287. form,
  288. res => {
  289. if (res.code == "ok") {
  290. this.$message({
  291. message: "保养完成",
  292. type: "success"
  293. });
  294. } else {
  295. this.$message({
  296. message: res.msg,
  297. type: "error"
  298. });
  299. }
  300. },
  301. error => {
  302. this.listLoading = false;
  303. this.$message({
  304. message: error,
  305. type: "error"
  306. });
  307. }
  308. );
  309. }
  310. },
  311. created() {
  312. let height = window.innerHeight;
  313. this.tableHeight = height - 260;
  314. },
  315. mounted() {
  316. this.mouldId = this.$route.params.id; //传到当前页面的模具编号
  317. // this.getList();
  318. this.getDetail();
  319. }
  320. };
  321. </script>
  322. <style scoped>
  323. .toolbar .el-form-item {
  324. font-size: 14px;
  325. vertical-align: middle;
  326. }
  327. .back {
  328. font-size: 16px;
  329. }
  330. .divLine {
  331. width: 2px;
  332. background: #c3c3c3;
  333. height: 100%;
  334. }
  335. .projectTitle {
  336. font-size: 18px;
  337. color: #333;
  338. }
  339. </style>