123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <template>
- <section>
- <!--工具条-->
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true" :model="filters">
- <el-col :span="3">
- <el-form-item>
- <el-select v-model="filters.projectId" clearable placeholder="请选择项目">
- <el-option v-for="item in projects" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="2">
- <el-form-item>
- <el-select v-model="filters.searchType" placeholder="请选择查询条件">
- <el-option label="编号" value="0"></el-option>
- <el-option label="名称" value="1"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-form-item>
- <el-input v-model="filters.keyName" placeholder="请输入编号或名称进行搜索"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="getMoldList">查询</el-button>
- </el-form-item>
- <el-form-item style="float: right" v-if="user.parentId == 1 && user.subordinateType == 0">
- <el-button type="primary" @click="showAdd">新建</el-button>
- </el-form-item>
- </el-form>
- </el-col>
- <!--列表-->
- <el-table :data="molds" :height="tableHeight" highlight-current-row v-loading="listLoading" style="width: 100%;">
- <el-table-column type="index" width="40"></el-table-column>
- <el-table-column prop="modelName" label="模具名称" width="140" sortable>
- <template slot-scope="scope">
- <el-link :underline="false" type="primary" @click="toDetail(scope.row)">{{scope.row.modelName}}</el-link>
- </template>
- </el-table-column>
- <el-table-column prop="modelNo" label="模具编号" width="120" sortable></el-table-column>
- <el-table-column prop="equipmentNo" label="云模盒编号" width="120" sortable></el-table-column>
- <el-table-column prop="hillNumber" label="电量" align="center" width="100" sortable></el-table-column>
- <el-table-column prop="diffTime" label="倒计时" align="center" width="100" sortable></el-table-column>
- <el-table-column prop="projectName" label="所属项目" width="140" sortable></el-table-column>
- <el-table-column prop="companyName" label="所属资产方" width="300" sortable></el-table-column>
- <el-table-column prop="produceCompany" label="所属生产方" width="200" sortable></el-table-column>
- <el-table-column prop="initialModulus" label="初始模次" width="100" align="center" sortable></el-table-column>
- <el-table-column prop="settingLife" label="模次寿命" width="100" align="center" sortable></el-table-column>
- <el-table-column prop="holes" label="穴数" width="100" align="center" sortable></el-table-column>
- <el-table-column prop="rfid" label="对应RFID码" width="120" align="center" sortable></el-table-column>
- <el-table-column label="状态" width="100" align="center" sortable>
- <template slot-scope="scope">
- <span v-if="scope.row.state == 1" style="color:#00CD66;">运行</span>
- <span v-else style="color:#999999;">静止</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="150" align="center" sortable v-if="user.parentId == 1 && user.subordinateType == 0">
- <template slot-scope="scope">
- <el-button size="small" type="danger" @click="handleDel(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!--工具条-->
- <el-col :span="24" class="toolbar">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :page-sizes="[20 , 50 , 80 , 100]"
- :page-size="20"
- layout="total, sizes, prev, pager, next"
- :total="total"
- style="float:right;"
- ></el-pagination>
- </el-col>
- <!--新增界面-->
- <el-dialog title="新建模具" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth">
- <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
- <el-form-item label="模具名称" prop="modelName">
- <el-input v-model="addForm.modelName" autocomplete="off" placeholder="请输入模具名称" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="模具编号" prop="modelNo">
- <el-input v-model="addForm.modelNo" autocomplete="off" placeholder="请输入模具编号" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="云模盒编号" prop="equipmentId">
- <el-select v-model="addForm.equipmentId" clearable filterable placeholder="请选择云模盒编号" style="width:202px">
- <el-option v-for="item in boxes" :key="item.id" :label="item.equipmentNo" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="初始模次" prop="initialModulus">
- <el-input v-model="addForm.initialModulus" autocomplete="off" placeholder="请输入初始模次" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="模次寿命" prop="settingLife">
- <el-input v-model="addForm.settingLife" autocomplete="off" placeholder="请输入模次寿命" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="RIFD码" prop="rfid">
- <el-input v-model="addForm.rfid" autocomplete="off" placeholder="请输入RIFD码" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="穴数" prop="holes">
- <el-input v-model="addForm.holes" autocomplete="off" placeholder="请输入穴数" style="width:202px"></el-input>
- </el-form-item>
- <el-form-item label="所属生产方" prop="produceCompanyId">
- <el-select v-model="addForm.produceCompanyId" clearable filterable placeholder="请选择所属生产方" style="width:202px">
- <el-option v-for="item in companys" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="保养次数" prop="maintainCount">
- <el-select v-model="addForm.maintainCount" clearable multiple allow-create filterable default-first-option placeholder="请选择保养次数" style="width:515px">
- <el-option v-for="item in maintainCount" :key="item" :label="item" :value="item"></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click.native="addFormVisible = false">取消</el-button>
- <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
- </div>
- </el-dialog>
- </section>
- </template>
- <script>
- import util from "../../common/js/util";
- export default {
- data() {
- const checkInitialModulus = (rule, value, callback) => {
- if (!value) {
- return callback(new Error('请输入初始模次'));
- } else {
- if((/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value) == false){
- callback(new Error("请填写大于0的数字"));
- }else{
- if (value > 100000000) {
- callback(new Error("请填写小于等于1亿的数字"));
- }else{
- callback();
- }
- }
- }
- };
- const checkSettingLife = (rule, value, callback) => {
- if (!value) {
- return callback(new Error('请输入模次寿命'));
- } else {
- if((/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value) == false){
- callback(new Error("请填写大于0的数字"));
- }else{
- if (value > 100000000) {
- callback(new Error("请填写小于等于1亿的数字"));
- }else{
- callback();
- }
- }
- }
- };
- return {
- user: JSON.parse(sessionStorage.getItem("user")),
- molds: [],
- filters: {
- keyName: "",
- searchType: "编号",
- projectId: ""
- },
- team: [{label:'资产方',value:0},{label:'生产方',value:1}],
- formRules: {
- modelNo: [
- { required: true, message: "请输入模具编号", trigger: "blur" }
- ],
- modelName: [
- { required: true, message: "请输入模具名称", trigger: "blur" }
- ],
- equipmentId: [
- { required: true, message: "请选择云模盒编号", trigger: ["blur", "change"] }
- ],
- initialModulus: [
- // { required: true, message: "请输入初始模次", trigger: "blur" }
- { required: true, validator: checkInitialModulus, trigger: 'blur'}
- ],
- settingLife: [
- // { required: true, message: "请输入模次寿命", trigger: "blur" }
- { required: true, validator: checkSettingLife, trigger: 'blur'}
- ],
- rfid: [
- { required: true, message: "请输入RIFD码", trigger: "blur" }
- ],
- holes: [
- { required: true, message: "请输入穴数", trigger: "blur" }
- ],
- produceCompanyId: [
- { required: true, message: "请选择所属生产方", trigger: ["blur", "change"] }
- ],
- maintainCount: [
- { required: true, message: "请输入保养次数", trigger: ["blur", "change"] }
- ]
- },
- listLoading: false,
- total: 0,
- size: 20,
- tableHeight: 0,
- boxes: [],
- companys: [],
- projects: [],
- maintainCount: [5000,10000,15000,20000,25000],
- addLoading: false,
- addFormVisible: false,
- addForm: {
- modelNo: "",
- modelName: "",
- equipmentId: "",
- initialModulus: "",
- settingLife: "",
- maintainCount: [],
- rfid: "",
- holes: "",
- produceCompanyId: ""
- }
- };
- },
- methods: {
- //获取模具
- getMoulds(){
- this.http.post( this.port.base.moulds, {
- belongCompanyId: this.user.companyId
- },
- res => {
- if (res.code == "ok") {
- this.boxes = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- getMsg() {
- //获取模具
- this.getMoulds();
- //新版获取公司
- this.http.post(this.port.base.relationList, {
- companyType: 1
- }, res => {
- if (res.code == "ok") {
- this.companys = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- });
-
- },
- getPro() {
- //获取项目
- this.http.post( this.port.project.projects, {},
- res => {
- if (res.code == "ok") {
- this.projects = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- //分页
- handleCurrentChange(val) {
- this.page = val;
- this.getMoldList();
- },
- handleSizeChange(val) {
- this.size = val;
- this.getMoldList();
- },
- //获取模具列表
- getMoldList() {
- this.listLoading = true;
- this.http.post( this.port.mold.molds, {
- keyName: this.filters.keyName,
- pageNum: this.page,
- pageSize: this.size,
- projectId: this.filters.projectId == "" ? -1 : this.filters.projectId,
- searchType: this.filters.searchType == "编号"? 0:1
- },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- var list = res.data.list
- for(var i in list){
- if(list[i].endTime == null){
- list[i].diffTime = "";
- } else {
- list[i].diffTime = util.formatDate.dateDiff(
- // util.formatDate.format(new Date(list[i].endTime), 'yyyy-MM-dd'),
- list[i].endTime,
- util.formatDate.format(new Date(new Date()), 'yyyy-MM-dd')
- );
- }
- }
- this.molds = list;
- this.total = res.data.total;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- //详情
- toDetail(row) {
- this.$router.push("/moldList/" + row.id + "/0");
- },
- //删除
- handleDel: function (row) {
- this.$confirm('确认删除该模具吗?', '提示', {
- type: 'warning'
- }).then(() => {
- this.http.post(this.port.mold.delMold, {
- id: row.id
- }, res => {
- if (res.code == "ok") {
- this.$message({
- message: '删除成功',
- type: 'success'
- });
- this.getMoldList();
- } else {
- this.$message({
- message: res.msg,
- type: 'error'
- });
- }
- }, error => {
- this.$message({
- message: error,
- type: 'error'
- });
- })
- });
- },
- //添加界面
- showAdd() {
- this.getMoulds();
- this.addFormVisible = true;
- this.addForm = {
- modelNo: "",
- modelName: "",
- equipmentId: "",
- initialModulus: "",
- settingLife: "",
- maintainCount: [],
- rfid: "",
- holes: "",
- produceCompanyId: ""
- };
- },
- addSubmit() {
- this.$refs.addForm.validate(valid => {
- if (valid) {
- this.addLoading = true;
- var maintainCount = this.addForm.maintainCount , str = "";
- for(var i in maintainCount) {
- if(i == maintainCount.length-1){
- str += maintainCount[i]
- } else {
- str += maintainCount[i] + ","
- }
- }
- this.addForm.maintainCount = str;
- this.http.post( this.port.mold.addMold, this.addForm,
- res => {
- this.addLoading = false;
- if (res.code == "ok") {
- this.addFormVisible = false;
- this.$message({
- message: "创建成功",
- type: "success"
- });
- this.getMoldList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.addLoading = false;
- this.addFormVisible = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- });
- },
- },
- created() {
- let height = window.innerHeight;
- this.tableHeight = height - 210;
- const that = this;
- window.onresize = function temp() {
- that.tableHeight = window.innerHeight - 210;
- };
- },
- mounted() {
- var user = JSON.parse(sessionStorage.getItem("user"));
- if(user.parentId == 1 && user.subordinateType == 0){
- this.getMsg();
- }
- this.getPro()
- this.getMoldList();
- }
- };
- </script>
- <style scoped>
- </style>
|