Browse Source

修改bug

姚云青 3 years ago
parent
commit
ae04e9f332

+ 352 - 352
imcs-ui/src/views/zuihou/prepareProductMgr/technologyVersion/components/programForm/components/ProgramMgr.vue

@@ -1,352 +1,352 @@
-<template>
-	<div class="uploadProgram">
-	    <el-form ref="form" :model="tenant" :disabled="formDisabled" :rules="rules" label-position="right" label-width="130px">
-	    	<!-- 上传程序 -->
-	      	<el-form-item :label='$t("resource.form.pgUpload")+":"' prop="filePath">
-	      		<el-input v-model="tenant.filePath" :readOnly="true" :placeholder='$t("common.pleaseEnter")'/>
-	          	<el-upload
-	          		accept=".*"
-				  	class="upload-demo"
-				  	:headers="headers"
-				  	:action="action"
-				  	:data="fileOtherData"
-				  	:on-preview="handlePreview"
-				  	:on-remove="handleRemove"
-				  	:before-remove="beforeRemove"
-				  	:on-success="handleSuccess"
-				  	:on-error='handleError'
-				  	:on-progress="handlePropress"
-				  	multiple
-				  	:limit="1"
-				  	:on-exceed="handleExceed"
-				  	:file-list="fileList">
-				  <el-button size="small" type="primary">{{$t("common.upload")}}</el-button>
-				  <!--<div slot="tip" class="el-upload__tip">{{$t("resource.tips.fileTips")}}</div>-->
-				</el-upload>
-	      	</el-form-item>
-	      	<!-- 优先级 -->
-		    <el-form-item :label='$t("resource.form.prority")+":"' prop="prority">
-		        <el-input v-model="tenant.prority" :placeholder='$t("common.pleaseEnter")' style="width: 100%;"/>
-		    </el-form-item>
-	      	<!-- 程序内容 -->
-	      	<el-form-item :label='$t("resource.form.pgContent")+":"' prop="pgContent">
-	        	<el-input v-model="pgContent" :readOnly="true" type="textarea" :rows="6" style="width: 100%;"/>
-	      	</el-form-item>
-	      	<!-- 刀具解析结果 -->
-	      	<div>
-	      	<h2 class="editTitle">{{$t("prepare.common.toolfx")}}</h2>
-	      		<el-table
-			      :data="toolList"
-			      style="width: 100%"
-			    >
-			      <el-table-column prop="specification" :label='$t("resource.table.programTool.specification")'></el-table-column>
-			      <el-table-column prop="model" :label='$t("resource.table.programTool.model")'></el-table-column>
-			      <el-table-column prop="brand" :label='$t("resource.table.programTool.brand")'></el-table-column>
-			      <el-table-column prop="usageTime" :label='$t("resource.table.programTool.usageTime")'></el-table-column>
-			      <el-table-column prop="duration" :label='$t("resource.table.programTool.duration")'></el-table-column>
-			    </el-table>
-	      	</div>
-	      
-	    </el-form>
-	    <div slot="footer" class="dialog-footer" style="margin-top: 15px;text-align: right;">
-	      <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
-	      <el-button plain type="primary" :disabled="subBtn" @click="submitForm">{{ $t('common.confirm') }}</el-button>
-	    </div>
-    </div>
-</template>
-<script>
-// 【程序中心】-API
-import programCenterApi from "@/api/resourceProductMgr/programCenter"
-// 【设备(生产资源)】-API
-import productionResourcesMgrApi from "@/api/resourceProductMgr/productionResourcesMgr"
-import db from "@/utils/localstorage";
-import {Base64} from 'js-base64';
-export default {
-  name: 'TenantEdit',
-  props: {
-  	programId: String,
-    dialogVisible: {
-      type: Boolean,
-      default: false
-    },
-    title: {
-      type: String,
-      default: ''
-    }
-  },
-  data () {
-    return {
-    	subBtn: false,
-    	formDisabled: false,
-    	tableData: [],
-    	eqList: [], // 设备下拉类别数据
-    	toolList: [], // 刀具列表
-    	pgContent: '',  // 程序内容
-      type: 'add',
-      tenant: this.initTenant(),
-      screenWidth: 0,
-      width: this.initWidth(),
-      confirmDisabled: false,
-      // 附件上传
-      action: `${process.env.VUE_APP_BASE_API}/file/attachment/upload`,
-      // 附件其它参数
-      fileOtherData: {
-      	bizId: "",
-        bizType: "PROGRAM"
-      },
-      // 附件的值
-      fileList: [/*
-      	{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, 
-      	{name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
-      */],
-      rules: {
-      	no: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
-        ],
-        name: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
-        ],
-        prority: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
-        ],
-        programSuitList: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'change' }
-        ],
-        filePath: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
-        ],
-        version: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
-        ]
-      }
-    }
-  },
-  	// 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
-	created() {
-		// 查询【程序】信息
-		if(!!this.programId){
-			this.getProgram(this.programId)
-		}
-	},
-	watch: {
-		programId(val){
-			console.log("值变化了:", val)
-			// 查询【程序】信息
-	  		this.getProgram(val)
-		}
-	},
-  computed: {
-  	headers() {
-      return {
-        token: 'Bearer ' + db.get("TOKEN", ""),
-        tenant: db.get("TENANT", "") || "",
-        Authorization: `Basic ${Base64.encode(`${process.env.VUE_APP_CLIENT_ID}:${process.env.VUE_APP_CLIENT_SECRET}`)}`
-      };
-    },
-    isVisible: {
-      get () {
-        return this.dialogVisible
-      },
-      set () {
-        this.close()
-        this.reset()
-      }
-    }
-  },
-  mounted () {
-    window.onresize = () => {
-      return (() => {
-        this.width = this.initWidth()
-      })()
-    }
-  },
-  methods: {
-  	// 文件列表移除文件时的钩子
-  	handleRemove(file, fileList) {
-	    console.log("删除事件:", file, fileList);
-	    // 还原数据
-	    this.resetFile()
-	  },
-	  // 点击文件列表中已上传的文件时的钩子
-	  handlePreview(file) {
-	    console.log("上传之前事件:",file);
-	  },
-	  // 文件超出个数限制时的钩子
-	  handleExceed(files, fileList) {
-	    this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
-	  },
-	  // 删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。
-	  beforeRemove(file, fileList) {
-	    return this.$confirm(`确定移除 ${ file.name }?`);
-	  },
-	  // 文件上传成功时的钩子
-	  handleSuccess(response, file, fileList){
-	  	console.log("文件上传成功!", response)
-	  	if(response.isSuccess){
-	  		// [上传程序]字段的值
-	  		this.tenant.filePath = response.data.url
-	  		// [程序大小]字段的值
-	  		this.tenant.size = response.data.size
-	  		// [程序id]
-	  		this.tenant.programId = response.data.bizId
-	  		// 查询【程序】信息
-	  		// this.getProgram(response.data.filename)
-	  		this.getProgram(response.data.bizId)
-	  	}
-	  },
-	  // 文件上传失败时的钩子
-	  handleError(err, file, fileList){
-	  	console.log("文件上传失败~", err)
-	  },
-	  // 文件上传时的钩子
-	  handlePropress(event, file, fileList){
-	  	console.log("文件上传~", event)
-	  },
-    initTenant () {
-      return {
-        id: '',
-        no: '',
-        name: '',
-        prority: '',
-        filePath: '',
-        size: null,
-        runTime: null
-      }
-    },
-    resetFile(){
-    	// [上传程序]字段的值
-  		this.tenant.filePath = ''
-  		// [程序大小]字段的值
-  		this.tenant.size = null
-  		// [运行时间]字段的值
-	  	this.tenant.runTime = null
-		// [程序内容]字段的值
-	  	this.pgContent = ''
-    },
-    initWidth () {
-      this.screenWidth = document.body.clientWidth
-      if (this.screenWidth < 991) {
-        return '90%'
-      } else if (this.screenWidth < 1400) {
-        return '45%'
-      } else {
-        return '800px'
-      }
-    },
-    setTenant (val) {
-    	if(val){
-    		this.tenant = { ...val }
-    		// 如果附件存在 /
-    		if(!!val.id){
-    			// 查询【程序】信息
-	  			this.getProgram(val.id)
-    		}
-    	}
-    },
-    close () {
-      this.$emit('close')
-    },
-    reset () {
-      // 先清除校验,再清除表单,不然有奇怪的bug
-      this.$refs.form.clearValidate()
-      this.$refs.form.resetFields()
-      this.tenant = this.initTenant()
-      // 【刀具】清空
-      this.toolList = []
-      // 【程序内容】清空
-      this.pgContent = ''
-      // 清空上传附件
-      this.fileList = []
-    },
-    submitForm () {
-      this.$refs.form.validate((valid) => {
-      	console.log("Form的数据:", this.tenant)
-        if (valid) {
-        	// 恢复按钮
-          	this.confirmDisabled = true
-          	// 传值父组件
-          	this.$emit("success", this.tenant)
-          	// 关闭
-          	this.$emit("close")
-          	// 初始化数据
-          	this.reset()
-        } else {
-          return false
-        }
-      })
-    },
-    // 【设备】下拉数据
-    equmentList() {
-    	productionResourcesMgrApi.getList({cncProgram: '1'}).then(res => {
-    		res = res.data
-    		// console.log("【设备】下拉数据:", res)
-    		if(res.isSuccess){
-    			this.eqList = res.data
-    		}
-    	})
-    },
-    // 根据[程序ID]获取文件内容 
-    getProgram(programId){
-    	programCenterApi.getProgram({id: programId}).then(res => {
-    		res = res.data 
-    		console.log("根据[程序ID]:", res.data)
-    		if(res.isSuccess){
-    			const obj = res.data
-    			// [程序内容]字段的值
-		  		this.pgContent = obj.content
-		  		// [刀具]列表
-		  		this.toolList = obj.toolList
-		  		// 附件数据
-		  		this.fileList = [{
-		  			name: obj.name,
-		  			url: obj.url
-		  		}]
-		  		// 需要回填的信息
-	  			this.tenant.nc = '1' // 表示已经上传
-	  			this.tenant.name = obj.name
-	  			this.tenant.filePath  = obj.url
-	  			this.tenant.runTime = obj.runTime
-	  			this.tenant.toolList = obj.toolList
-	  			this.tenant.toolNums = obj.toolList ? obj.toolList.length : 0
-    		}
-    	})
-    }
-
-  }
-}
-</script>
-<style lang="scss" scoped>
-.avatar-uploader .el-upload {
-  border: 1px dashed #d9d9d9;
-  border-radius: 6px;
-  cursor: pointer;
-  position: relative;
-  overflow: hidden;
-}
-.avatar-uploader .el-upload:hover {
-  border-color: #409eff;
-}
-.avatar-uploader-icon {
-  font-size: 28px;
-  color: #8c939d;
-  width: 100px;
-  height: 100px;
-  line-height: 100px;
-  text-align: center;
-}
-.avatar {
-  width: 100px;
-  height: 100px;
-  display: block;
-}
-.checkUsed{
-	display: inline-block;
-	margin-left: 10px;
-	color: #1890ff;
-}
-.editTitle{
-	font-size: 17px;
-	padding-bottom: 15px;
-	border-bottom: 1px solid #CCCCCC;
-}
-</style>
+<template>
+	<div class="uploadProgram">
+	    <el-form ref="form" :model="tenant" :disabled="formDisabled" :rules="rules" label-position="right" label-width="130px">
+	    	<!-- 上传程序 -->
+	      	<el-form-item :label='$t("resource.form.pgUpload")+":"' prop="filePath">
+	      		<el-input v-model="tenant.filePath" :readOnly="true" :placeholder='$t("common.pleaseEnter")'/>
+	          	<el-upload
+	          		accept=".*"
+				  	class="upload-demo"
+				  	:headers="headers"
+				  	:action="action"
+				  	:data="fileOtherData"
+				  	:on-preview="handlePreview"
+				  	:on-remove="handleRemove"
+				  	:before-remove="beforeRemove"
+				  	:on-success="handleSuccess"
+				  	:on-error='handleError'
+				  	:on-progress="handlePropress"
+				  	multiple
+				  	:limit="1"
+				  	:on-exceed="handleExceed"
+				  	:file-list="fileList">
+				  <el-button size="small" type="primary">{{$t("common.upload")}}</el-button>
+				  <!--<div slot="tip" class="el-upload__tip">{{$t("resource.tips.fileTips")}}</div>-->
+				</el-upload>
+	      	</el-form-item>
+	      	<!-- 优先级 -->
+		    <el-form-item :label='$t("resource.form.prority")+":"' prop="prority">
+		        <el-input v-model="tenant.prority" :placeholder='$t("common.pleaseEnter")' style="width: 100%;"/>
+		    </el-form-item>
+	      	<!-- 程序内容 -->
+	      	<el-form-item :label='$t("resource.form.pgContent")+":"' prop="pgContent">
+	        	<el-input v-model="pgContent" :readOnly="true" type="textarea" :rows="6" style="width: 100%;"/>
+	      	</el-form-item>
+	      	<!-- 刀具解析结果 -->
+	      	<div>
+	      	<h2 class="editTitle">{{$t("prepare.common.toolfx")}}</h2>
+	      		<el-table
+			      :data="toolList"
+			      style="width: 100%"
+			    >
+			      <el-table-column prop="specification" :label='$t("resource.table.programTool.specification")'></el-table-column>
+			      <el-table-column prop="model" :label='$t("resource.table.programTool.model")'></el-table-column>
+			      <el-table-column prop="brand" :label='$t("resource.table.programTool.brand")'></el-table-column>
+			      <el-table-column prop="usageTime" :label='$t("resource.table.programTool.usageTime")'></el-table-column>
+			      <el-table-column prop="duration" :label='$t("resource.table.programTool.duration")'></el-table-column>
+			    </el-table>
+	      	</div>
+
+	    </el-form>
+	    <div slot="footer" class="dialog-footer" style="margin-top: 15px;text-align: right;">
+	      <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
+	      <el-button plain type="primary" :disabled="subBtn" @click="submitForm">{{ $t('common.confirm') }}</el-button>
+	    </div>
+    </div>
+</template>
+<script>
+// 【程序中心】-API
+import programCenterApi from "@/api/resourceProductMgr/programCenter"
+// 【设备(生产资源)】-API
+import productionResourcesMgrApi from "@/api/resourceProductMgr/productionResourcesMgr"
+import db from "@/utils/localstorage";
+import {Base64} from 'js-base64';
+export default {
+  name: 'TenantEdit',
+  props: {
+  	programId: String,
+    dialogVisible: {
+      type: Boolean,
+      default: false
+    },
+    title: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+    	subBtn: false,
+    	formDisabled: false,
+    	tableData: [],
+    	eqList: [], // 设备下拉类别数据
+    	toolList: [], // 刀具列表
+    	pgContent: '',  // 程序内容
+      type: 'add',
+      tenant: this.initTenant(),
+      screenWidth: 0,
+      width: this.initWidth(),
+      confirmDisabled: false,
+      // 附件上传
+      action: `${process.env.VUE_APP_BASE_API}/file/attachment/upload`,
+      // 附件其它参数
+      fileOtherData: {
+      	bizId: "",
+        bizType: "PROGRAM"
+      },
+      // 附件的值
+      fileList: [/*
+      	{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'},
+      	{name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
+      */],
+      rules: {
+      	no: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        ],
+        name: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        ],
+        prority: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        ],
+        programSuitList: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'change' }
+        ],
+        filePath: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        ],
+        version: [
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  	// 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
+	created() {
+		// 查询【程序】信息
+		if(!!this.programId){
+			this.getProgram(this.programId)
+		}
+	},
+	watch: {
+		programId(val){
+			console.log("值变化了:", val)
+			// 查询【程序】信息
+	  		this.getProgram(val)
+		}
+	},
+  computed: {
+  	headers() {
+      return {
+        token: 'Bearer ' + db.get("TOKEN", ""),
+        tenant: db.get("TENANT", "") || "",
+        Authorization: `Basic ${Base64.encode(`${process.env.VUE_APP_CLIENT_ID}:${process.env.VUE_APP_CLIENT_SECRET}`)}`
+      };
+    },
+    isVisible: {
+      get () {
+        return this.dialogVisible
+      },
+      set () {
+        this.close()
+        this.reset()
+      }
+    }
+  },
+  mounted () {
+    window.onresize = () => {
+      return (() => {
+        this.width = this.initWidth()
+      })()
+    }
+  },
+  methods: {
+  	// 文件列表移除文件时的钩子
+  	handleRemove(file, fileList) {
+	    console.log("删除事件:", file, fileList);
+	    // 还原数据
+	    this.resetFile()
+	  },
+	  // 点击文件列表中已上传的文件时的钩子
+	  handlePreview(file) {
+	    console.log("上传之前事件:",file);
+	  },
+	  // 文件超出个数限制时的钩子
+	  handleExceed(files, fileList) {
+	    this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
+	  },
+	  // 删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。
+	  beforeRemove(file, fileList) {
+	    return this.$confirm(`确定移除 ${ file.name }?`);
+	  },
+	  // 文件上传成功时的钩子
+	  handleSuccess(response, file, fileList){
+	  	console.log("文件上传成功!", response)
+	  	if(response.isSuccess){
+	  		// [上传程序]字段的值
+	  		this.tenant.filePath = response.data.url
+	  		// [程序大小]字段的值
+	  		this.tenant.size = response.data.size
+	  		// [程序id]
+	  		this.tenant.programId = response.data.bizId
+	  		// 查询【程序】信息
+	  		// this.getProgram(response.data.filename)
+	  		this.getProgram(response.data.bizId)
+	  	}
+	  },
+	  // 文件上传失败时的钩子
+	  handleError(err, file, fileList){
+	  	console.log("文件上传失败~", err)
+	  },
+	  // 文件上传时的钩子
+	  handlePropress(event, file, fileList){
+	  	console.log("文件上传~", event)
+	  },
+    initTenant () {
+      return {
+        id: '',
+        no: '',
+        name: '',
+        prority: '',
+        filePath: '',
+        size: null,
+        runTime: null
+      }
+    },
+    resetFile(){
+    	// [上传程序]字段的值
+  		this.tenant.filePath = ''
+  		// [程序大小]字段的值
+  		this.tenant.size = null
+  		// [运行时间]字段的值
+	  	this.tenant.runTime = null
+		// [程序内容]字段的值
+	  	this.pgContent = ''
+    },
+    initWidth () {
+      this.screenWidth = document.body.clientWidth
+      if (this.screenWidth < 991) {
+        return '90%'
+      } else if (this.screenWidth < 1400) {
+        return '45%'
+      } else {
+        return '800px'
+      }
+    },
+    setTenant (val) {
+    	if(val){
+    		this.tenant = { ...val }
+    		// 如果附件存在 /
+    		if(!!val.id){
+    			// 查询【程序】信息
+	  			this.getProgram(val.id)
+    		}
+    	}
+    },
+    close () {
+      this.$emit('close')
+    },
+    reset () {
+      // 先清除校验,再清除表单,不然有奇怪的bug
+      this.$refs.form.clearValidate()
+      this.$refs.form.resetFields()
+      this.tenant = this.initTenant()
+      // 【刀具】清空
+      this.toolList = []
+      // 【程序内容】清空
+      this.pgContent = ''
+      // 清空上传附件
+      this.fileList = []
+    },
+    submitForm () {
+      this.$refs.form.validate((valid) => {
+      	console.log("Form的数据:", this.tenant)
+        if (valid) {
+        	// 恢复按钮
+          	this.confirmDisabled = true
+          	// 传值父组件
+          	this.$emit("success", this.tenant)
+          	// 关闭
+          	this.$emit("close")
+          	// 初始化数据
+          	this.reset()
+        } else {
+          return false
+        }
+      })
+    },
+    // 【设备】下拉数据
+    equmentList() {
+    	productionResourcesMgrApi.getList({cncProgram: '1'}).then(res => {
+    		res = res.data
+    		// console.log("【设备】下拉数据:", res)
+    		if(res.isSuccess){
+    			this.eqList = res.data
+    		}
+    	})
+    },
+    // 根据[程序ID]获取文件内容
+    getProgram(programId){
+    	programCenterApi.getProgram({id: programId}).then(res => {
+    		res = res.data
+    		console.log("根据[程序ID]:", res.data)
+    		if(res.isSuccess){
+    			const obj = res.data
+    			// [程序内容]字段的值
+		  		this.pgContent = obj.content
+		  		// [刀具]列表
+		  		this.toolList = obj.toolList
+		  		// 附件数据
+		  		this.fileList = [{
+		  			name: obj.name,
+		  			url: obj.url
+		  		}]
+		  		// 需要回填的信息
+	  			this.tenant.nc = '1' // 表示已经上传
+	  			this.tenant.name = obj.name
+	  			this.tenant.filePath  = obj.url
+	  			this.tenant.runTime = obj.runTime
+	  			this.tenant.toolList = obj.toolList
+	  			this.tenant.toolNums = obj.toolList ? obj.toolList.length : 0
+    		}
+    	})
+    }
+
+  }
+}
+</script>
+<style lang="scss" scoped>
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409eff;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 100px;
+  height: 100px;
+  line-height: 100px;
+  text-align: center;
+}
+.avatar {
+  width: 100px;
+  height: 100px;
+  display: block;
+}
+.checkUsed{
+	display: inline-block;
+	margin-left: 10px;
+	color: #1890ff;
+}
+.editTitle{
+	font-size: 17px;
+	padding-bottom: 15px;
+	border-bottom: 1px solid #CCCCCC;
+}
+</style>