moldList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. size: 20,
  196. tableHeight: 0,
  197. boxes: [],
  198. companys: [],
  199. projects: [],
  200. maintainCount: [5000,10000,15000,20000,25000],
  201. addLoading: false,
  202. addFormVisible: false,
  203. addForm: {
  204. modelNo: "",
  205. modelName: "",
  206. equipmentId: "",
  207. initialModulus: "",
  208. settingLife: "",
  209. maintainCount: [],
  210. rfid: "",
  211. holes: "",
  212. produceCompanyId: ""
  213. }
  214. };
  215. },
  216. methods: {
  217. //获取模具
  218. getMoulds(){
  219. this.http.post( this.port.base.moulds, {
  220. belongCompanyId: this.user.companyId
  221. },
  222. res => {
  223. if (res.code == "ok") {
  224. this.boxes = res.data;
  225. } else {
  226. this.$message({
  227. message: res.msg,
  228. type: "error"
  229. });
  230. }
  231. },
  232. error => {
  233. this.listLoading = false;
  234. this.$message({
  235. message: error,
  236. type: "error"
  237. });
  238. });
  239. },
  240. getMsg() {
  241. //获取模具
  242. this.getMoulds();
  243. //新版获取公司
  244. this.http.post(this.port.base.relationList, {
  245. companyType: 1
  246. }, res => {
  247. if (res.code == "ok") {
  248. this.companys = res.data;
  249. } else {
  250. this.$message({
  251. message: res.msg,
  252. type: 'error'
  253. });
  254. }
  255. }, error => {
  256. this.$message({
  257. message: error,
  258. type: 'error'
  259. });
  260. });
  261. },
  262. getPro() {
  263. //获取项目
  264. this.http.post( this.port.project.projects, {},
  265. res => {
  266. if (res.code == "ok") {
  267. this.projects = res.data;
  268. } else {
  269. this.$message({
  270. message: res.msg,
  271. type: "error"
  272. });
  273. }
  274. },
  275. error => {
  276. this.listLoading = false;
  277. this.$message({
  278. message: error,
  279. type: "error"
  280. });
  281. });
  282. },
  283. //分页
  284. handleCurrentChange(val) {
  285. this.page = val;
  286. this.getMoldList();
  287. },
  288. handleSizeChange(val) {
  289. this.size = val;
  290. this.getMoldList();
  291. },
  292. //获取模具列表
  293. getMoldList() {
  294. this.listLoading = true;
  295. this.http.post( this.port.mold.molds, {
  296. keyName: this.filters.keyName,
  297. pageNum: this.page,
  298. pageSize: this.size,
  299. projectId: this.filters.projectId == "" ? -1 : this.filters.projectId,
  300. searchType: this.filters.searchType == "编号"? 0:1
  301. },
  302. res => {
  303. this.listLoading = false;
  304. if (res.code == "ok") {
  305. var list = res.data.list
  306. for(var i in list){
  307. if(list[i].endTime == null){
  308. list[i].diffTime = "";
  309. } else {
  310. list[i].diffTime = util.formatDate.dateDiff(
  311. // util.formatDate.format(new Date(list[i].endTime), 'yyyy-MM-dd'),
  312. list[i].endTime,
  313. util.formatDate.format(new Date(new Date()), 'yyyy-MM-dd')
  314. );
  315. }
  316. }
  317. this.molds = list;
  318. this.total = res.data.total;
  319. } else {
  320. this.$message({
  321. message: res.msg,
  322. type: "error"
  323. });
  324. }
  325. },
  326. error => {
  327. this.listLoading = false;
  328. this.$message({
  329. message: error,
  330. type: "error"
  331. });
  332. });
  333. },
  334. //详情
  335. toDetail(row) {
  336. this.$router.push("/moldList/" + row.id + "/0");
  337. },
  338. //删除
  339. handleDel: function (row) {
  340. this.$confirm('确认删除该模具吗?', '提示', {
  341. type: 'warning'
  342. }).then(() => {
  343. this.http.post(this.port.mold.delMold, {
  344. id: row.id
  345. }, res => {
  346. if (res.code == "ok") {
  347. this.$message({
  348. message: '删除成功',
  349. type: 'success'
  350. });
  351. this.getMoldList();
  352. } else {
  353. this.$message({
  354. message: res.msg,
  355. type: 'error'
  356. });
  357. }
  358. }, error => {
  359. this.$message({
  360. message: error,
  361. type: 'error'
  362. });
  363. })
  364. });
  365. },
  366. //添加界面
  367. showAdd() {
  368. this.getMoulds();
  369. this.addFormVisible = true;
  370. this.addForm = {
  371. modelNo: "",
  372. modelName: "",
  373. equipmentId: "",
  374. initialModulus: "",
  375. settingLife: "",
  376. maintainCount: [],
  377. rfid: "",
  378. holes: "",
  379. produceCompanyId: ""
  380. };
  381. },
  382. addSubmit() {
  383. this.$refs.addForm.validate(valid => {
  384. if (valid) {
  385. this.addLoading = true;
  386. var maintainCount = this.addForm.maintainCount , str = "";
  387. for(var i in maintainCount) {
  388. if(i == maintainCount.length-1){
  389. str += maintainCount[i]
  390. } else {
  391. str += maintainCount[i] + ","
  392. }
  393. }
  394. this.addForm.maintainCount = str;
  395. this.http.post( this.port.mold.addMold, this.addForm,
  396. res => {
  397. this.addLoading = false;
  398. if (res.code == "ok") {
  399. this.addFormVisible = false;
  400. this.$message({
  401. message: "创建成功",
  402. type: "success"
  403. });
  404. this.getMoldList();
  405. } else {
  406. this.$message({
  407. message: res.msg,
  408. type: "error"
  409. });
  410. }
  411. },
  412. error => {
  413. this.addLoading = false;
  414. this.addFormVisible = false;
  415. this.$message({
  416. message: error,
  417. type: "error"
  418. });
  419. });
  420. }
  421. });
  422. },
  423. },
  424. created() {
  425. let height = window.innerHeight;
  426. this.tableHeight = height - 210;
  427. const that = this;
  428. window.onresize = function temp() {
  429. that.tableHeight = window.innerHeight - 210;
  430. };
  431. },
  432. mounted() {
  433. var user = JSON.parse(sessionStorage.getItem("user"));
  434. if(user.parentId == 1 && user.subordinateType == 0){
  435. this.getMsg();
  436. }
  437. this.getPro()
  438. this.getMoldList();
  439. }
  440. };
  441. </script>
  442. <style scoped>
  443. </style>