moldList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true" :model="filters">
  6. <el-col :span="3">
  7. <el-form-item>
  8. <el-select v-model="filters.projectId" clearable placeholder="请选择项目">
  9. <el-option v-for="item in projects" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  10. </el-select>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="2">
  14. <el-form-item>
  15. <el-select v-model="filters.searchType" placeholder="请选择查询条件">
  16. <el-option label="编号" value="0"></el-option>
  17. <el-option label="名称" value="1"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. </el-col>
  21. <el-form-item>
  22. <el-input v-model="filters.keyName" placeholder="请输入编号或名称进行搜索"></el-input>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="getMoldList">查询</el-button>
  26. </el-form-item>
  27. <el-form-item style="float: right" v-if="user.parentId == 1 && user.subordinateType == 0">
  28. <el-button type="primary" @click="showAdd">新建</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </el-col>
  32. <!--列表-->
  33. <el-table :data="molds" :height="tableHeight" highlight-current-row v-loading="listLoading" style="width: 100%;">
  34. <el-table-column type="index" width="40"></el-table-column>
  35. <el-table-column prop="modelName" label="模具名称" width="140" sortable>
  36. <template slot-scope="scope">
  37. <el-link :underline="false" type="primary" @click="toDetail(scope.row)">{{scope.row.modelName}}</el-link>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="modelNo" label="模具编号" width="120" sortable></el-table-column>
  41. <el-table-column prop="equipmentNo" label="云模盒编号" width="120" sortable></el-table-column>
  42. <el-table-column prop="hillNumber" label="电量" align="center" width="100" sortable></el-table-column>
  43. <el-table-column prop="diffTime" label="倒计时" align="center" width="100" sortable></el-table-column>
  44. <el-table-column prop="projectName" label="所属项目" width="140" sortable></el-table-column>
  45. <el-table-column prop="companyName" label="所属资产方" width="300" sortable></el-table-column>
  46. <el-table-column prop="produceCompany" label="所属生产方" width="200" sortable></el-table-column>
  47. <el-table-column prop="initialModulus" label="初始模次" width="100" align="center" sortable></el-table-column>
  48. <el-table-column prop="settingLife" label="模次寿命" width="100" align="center" sortable></el-table-column>
  49. <el-table-column prop="holes" label="穴数" width="100" align="center" sortable></el-table-column>
  50. <el-table-column prop="rfid" label="对应RFID码" width="120" align="center" sortable></el-table-column>
  51. <el-table-column label="状态" width="100" align="center" sortable>
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.state == 1" style="color:#00CD66;">运行</span>
  54. <span v-else style="color:#999999;">静止</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" width="150" align="center" sortable v-if="user.parentId == 1 && user.subordinateType == 0">
  58. <template slot-scope="scope">
  59. <el-button size="small" type="danger" @click="handleDel(scope.row)">删除</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!--工具条-->
  64. <el-col :span="24" class="toolbar">
  65. <el-pagination
  66. @size-change="handleSizeChange"
  67. @current-change="handleCurrentChange"
  68. :page-sizes="[20 , 50 , 80 , 100]"
  69. :page-size="20"
  70. layout="total, sizes, prev, pager, next"
  71. :total="total"
  72. style="float:right;"
  73. ></el-pagination>
  74. </el-col>
  75. <!--新增界面-->
  76. <el-dialog title="新建模具" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth">
  77. <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
  78. <el-form-item label="模具名称" prop="modelName">
  79. <el-input v-model="addForm.modelName" autocomplete="off" placeholder="请输入模具名称" style="width:202px"></el-input>
  80. </el-form-item>
  81. <el-form-item label="模具编号" prop="modelNo">
  82. <el-input v-model="addForm.modelNo" autocomplete="off" placeholder="请输入模具编号" style="width:202px"></el-input>
  83. </el-form-item>
  84. <el-form-item label="云模盒编号" prop="equipmentId">
  85. <el-select v-model="addForm.equipmentId" clearable filterable placeholder="请选择云模盒编号" style="width:202px">
  86. <el-option v-for="item in boxes" :key="item.id" :label="item.equipmentNo" :value="item.id"></el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="初始模次" prop="initialModulus">
  90. <el-input v-model="addForm.initialModulus" autocomplete="off" placeholder="请输入初始模次" style="width:202px"></el-input>
  91. </el-form-item>
  92. <el-form-item label="模次寿命" prop="settingLife">
  93. <el-input v-model="addForm.settingLife" autocomplete="off" placeholder="请输入模次寿命" style="width:202px"></el-input>
  94. </el-form-item>
  95. <el-form-item label="RIFD码" prop="rfid">
  96. <el-input v-model="addForm.rfid" autocomplete="off" placeholder="请输入RIFD码" style="width:202px"></el-input>
  97. </el-form-item>
  98. <el-form-item label="穴数" prop="holes">
  99. <el-input v-model="addForm.holes" autocomplete="off" placeholder="请输入穴数" style="width:202px"></el-input>
  100. </el-form-item>
  101. <el-form-item label="所属生产方" prop="produceCompanyId">
  102. <el-select v-model="addForm.produceCompanyId" clearable filterable placeholder="请选择所属生产方" style="width:202px">
  103. <el-option v-for="item in companys" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item label="保养次数" prop="maintainCount">
  107. <el-select v-model="addForm.maintainCount" clearable multiple allow-create filterable default-first-option placeholder="请选择保养次数" style="width:515px">
  108. <el-option v-for="item in maintainCount" :key="item" :label="item" :value="item"></el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button @click.native="addFormVisible = false">取消</el-button>
  114. <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
  115. </div>
  116. </el-dialog>
  117. </section>
  118. </template>
  119. <script>
  120. import util from "../../common/js/util";
  121. export default {
  122. data() {
  123. const checkInitialModulus = (rule, value, callback) => {
  124. if (!value) {
  125. return callback(new Error('请输入初始模次'));
  126. } else {
  127. if((/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value) == false){
  128. callback(new Error("请填写大于0的数字"));
  129. }else{
  130. if (value > 100000000) {
  131. callback(new Error("请填写小于等于1亿的数字"));
  132. }else{
  133. callback();
  134. }
  135. }
  136. }
  137. };
  138. const checkSettingLife = (rule, value, callback) => {
  139. if (!value) {
  140. return callback(new Error('请输入模次寿命'));
  141. } else {
  142. if((/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value) == false){
  143. callback(new Error("请填写大于0的数字"));
  144. }else{
  145. if (value > 100000000) {
  146. callback(new Error("请填写小于等于1亿的数字"));
  147. }else{
  148. callback();
  149. }
  150. }
  151. }
  152. };
  153. return {
  154. user: JSON.parse(sessionStorage.getItem("user")),
  155. molds: [],
  156. filters: {
  157. keyName: "",
  158. searchType: "编号",
  159. projectId: ""
  160. },
  161. team: [{label:'资产方',value:0},{label:'生产方',value:1}],
  162. formRules: {
  163. modelNo: [
  164. { required: true, message: "请输入模具编号", trigger: "blur" }
  165. ],
  166. modelName: [
  167. { required: true, message: "请输入模具名称", trigger: "blur" }
  168. ],
  169. equipmentId: [
  170. { required: true, message: "请选择云模盒编号", trigger: ["blur", "change"] }
  171. ],
  172. initialModulus: [
  173. // { required: true, message: "请输入初始模次", trigger: "blur" }
  174. { required: true, validator: checkInitialModulus, trigger: 'blur'}
  175. ],
  176. settingLife: [
  177. // { required: true, message: "请输入模次寿命", trigger: "blur" }
  178. { required: true, validator: checkSettingLife, trigger: 'blur'}
  179. ],
  180. rfid: [
  181. { required: true, message: "请输入RIFD码", trigger: "blur" }
  182. ],
  183. holes: [
  184. { required: true, message: "请输入穴数", trigger: "blur" }
  185. ],
  186. produceCompanyId: [
  187. { required: true, message: "请选择所属生产方", trigger: ["blur", "change"] }
  188. ],
  189. maintainCount: [
  190. { required: true, message: "请输入保养次数", trigger: ["blur", "change"] }
  191. ]
  192. },
  193. listLoading: false,
  194. total: 0,
  195. tableHeight: 0,
  196. boxes: [],
  197. companys: [],
  198. projects: [],
  199. maintainCount: [5000,10000,15000,20000,25000],
  200. addLoading: false,
  201. addFormVisible: false,
  202. addForm: {
  203. modelNo: "",
  204. modelName: "",
  205. equipmentId: "",
  206. initialModulus: "",
  207. settingLife: "",
  208. maintainCount: [],
  209. rfid: "",
  210. holes: "",
  211. produceCompanyId: ""
  212. }
  213. };
  214. },
  215. methods: {
  216. //获取模具
  217. getMoulds(){
  218. this.http.post( this.port.base.moulds, {
  219. belongCompanyId: this.user.companyId
  220. },
  221. res => {
  222. if (res.code == "ok") {
  223. this.boxes = res.data;
  224. } else {
  225. this.$message({
  226. message: res.msg,
  227. type: "error"
  228. });
  229. }
  230. },
  231. error => {
  232. this.listLoading = false;
  233. this.$message({
  234. message: error,
  235. type: "error"
  236. });
  237. });
  238. },
  239. getMsg() {
  240. //获取模具
  241. this.getMoulds();
  242. //新版获取公司
  243. this.http.post(this.port.base.relationList, {
  244. companyType: 1
  245. }, res => {
  246. if (res.code == "ok") {
  247. this.companys = res.data;
  248. } else {
  249. this.$message({
  250. message: res.msg,
  251. type: 'error'
  252. });
  253. }
  254. }, error => {
  255. this.$message({
  256. message: error,
  257. type: 'error'
  258. });
  259. });
  260. },
  261. getPro() {
  262. //获取项目
  263. this.http.post( this.port.project.projects, {},
  264. res => {
  265. if (res.code == "ok") {
  266. this.projects = res.data;
  267. } else {
  268. this.$message({
  269. message: res.msg,
  270. type: "error"
  271. });
  272. }
  273. },
  274. error => {
  275. this.listLoading = false;
  276. this.$message({
  277. message: error,
  278. type: "error"
  279. });
  280. });
  281. },
  282. //分页
  283. handleCurrentChange(val) {
  284. this.page = val;
  285. this.getMoldList();
  286. },
  287. handleSizeChange(val) {
  288. this.size = val;
  289. this.getMoldList();
  290. },
  291. //获取模具列表
  292. getMoldList() {
  293. this.listLoading = true;
  294. this.http.post( this.port.mold.molds, {
  295. keyName: this.filters.keyName,
  296. pageNum: this.page,
  297. pageSize: this.size,
  298. projectId: this.filters.projectId == "" ? -1 : this.filters.projectId,
  299. searchType: this.filters.searchType == "编号"? 0:1
  300. },
  301. res => {
  302. this.listLoading = false;
  303. if (res.code == "ok") {
  304. var list = res.data.list
  305. for(var i in list){
  306. if(list[i].endTime == null){
  307. list[i].diffTime = "";
  308. } else {
  309. list[i].diffTime = util.formatDate.dateDiff(
  310. util.formatDate.format(new Date(list[i].endTime), 'yyyy-MM-dd'),
  311. util.formatDate.format(new Date(new Date()), 'yyyy-MM-dd')
  312. );
  313. }
  314. }
  315. this.molds = list;
  316. this.total = res.data.total;
  317. } else {
  318. this.$message({
  319. message: res.msg,
  320. type: "error"
  321. });
  322. }
  323. },
  324. error => {
  325. this.listLoading = false;
  326. this.$message({
  327. message: error,
  328. type: "error"
  329. });
  330. });
  331. },
  332. //详情
  333. toDetail(row) {
  334. this.$router.push("/moldList/" + row.id + "/0");
  335. },
  336. //删除
  337. handleDel: function (row) {
  338. this.$confirm('确认删除该模具吗?', '提示', {
  339. type: 'warning'
  340. }).then(() => {
  341. this.http.post(this.port.mold.delMold, {
  342. id: row.id
  343. }, res => {
  344. if (res.code == "ok") {
  345. this.$message({
  346. message: '删除成功',
  347. type: 'success'
  348. });
  349. this.getMoldList();
  350. } else {
  351. this.$message({
  352. message: res.msg,
  353. type: 'error'
  354. });
  355. }
  356. }, error => {
  357. this.$message({
  358. message: error,
  359. type: 'error'
  360. });
  361. })
  362. });
  363. },
  364. //添加界面
  365. showAdd() {
  366. this.getMoulds();
  367. this.addFormVisible = true;
  368. this.addForm = {
  369. modelNo: "",
  370. modelName: "",
  371. equipmentId: "",
  372. initialModulus: "",
  373. settingLife: "",
  374. maintainCount: [],
  375. rfid: "",
  376. holes: "",
  377. produceCompanyId: ""
  378. };
  379. },
  380. addSubmit() {
  381. this.$refs.addForm.validate(valid => {
  382. if (valid) {
  383. this.addLoading = true;
  384. var maintainCount = this.addForm.maintainCount , str = "";
  385. for(var i in maintainCount) {
  386. if(i == maintainCount.length-1){
  387. str += maintainCount[i]
  388. } else {
  389. str += maintainCount[i] + ","
  390. }
  391. }
  392. this.addForm.maintainCount = str;
  393. this.http.post( this.port.mold.addMold, this.addForm,
  394. res => {
  395. this.addLoading = false;
  396. if (res.code == "ok") {
  397. this.addFormVisible = false;
  398. this.$message({
  399. message: "创建成功",
  400. type: "success"
  401. });
  402. this.getMoldList();
  403. } else {
  404. this.$message({
  405. message: res.msg,
  406. type: "error"
  407. });
  408. }
  409. },
  410. error => {
  411. this.addLoading = false;
  412. this.addFormVisible = false;
  413. this.$message({
  414. message: error,
  415. type: "error"
  416. });
  417. });
  418. }
  419. });
  420. },
  421. },
  422. created() {
  423. let height = window.innerHeight;
  424. this.tableHeight = height - 210;
  425. const that = this;
  426. window.onresize = function temp() {
  427. that.tableHeight = window.innerHeight - 210;
  428. };
  429. },
  430. mounted() {
  431. var user = JSON.parse(sessionStorage.getItem("user"));
  432. if(user.parentId == 1 && user.subordinateType == 0){
  433. this.getMsg();
  434. }
  435. this.getPro()
  436. this.getMoldList();
  437. }
  438. };
  439. </script>
  440. <style scoped>
  441. </style>