yaoyq 3 anni fa
parent
commit
3fdaa8f161

+ 2 - 0
imcs-ui/src/lang/zh/resource.js

@@ -77,6 +77,7 @@ export default {
 	  		tongbu: '同步刀具',
 	  		tongbu: '同步刀具',
 	  		tongbEq: '同步到设备',
 	  		tongbEq: '同步到设备',
 	  		tongbSk: '同步数控程序',
 	  		tongbSk: '同步数控程序',
+        upload: '上传程序',
 			mode:  '模式',
 			mode:  '模式',
 			autoCode: '设备业务自动化节点',
 			autoCode: '设备业务自动化节点',
 			detailConf: '详情配置'
 			detailConf: '详情配置'
@@ -278,6 +279,7 @@ export default {
 			tray_num: '可放子盘数量',
 			tray_num: '可放子盘数量',
 			arm: '手抓',
 			arm: '手抓',
 			armName: '手抓名称',
 			armName: '手抓名称',
+      target_resource: '目标设备',
 			rouJiagong: '产线类型'
 			rouJiagong: '产线类型'
 		},
 		},
 		// 表单验证规则提示信息
 		// 表单验证规则提示信息

+ 41 - 1
imcs-ui/src/views/zuihou/resourceProductMgr/equipmentProgramMgr/Index.vue

@@ -31,6 +31,7 @@
     <el-row class="filter-container">
     <el-row class="filter-container">
     	<el-col>
     	<el-col>
     		<el-button type="primary" icon="el-icon-connection" size="medium" @click="synchronousTool">{{$t("resource.buttons.tongbSk")}}</el-button>
     		<el-button type="primary" icon="el-icon-connection" size="medium" @click="synchronousTool">{{$t("resource.buttons.tongbSk")}}</el-button>
+        <el-button type="primary" icon="el-icon-connection" size="medium" @click="editUpload">{{$t("resource.buttons.upload")}}</el-button>
     	</el-col>
     	</el-col>
     </el-row>
     </el-row>
 
 
@@ -199,6 +200,15 @@
       :dialog-visible="tenantViewVisible"
       :dialog-visible="tenantViewVisible"
       @close="viewClose"
       @close="viewClose"
     />
     />
+
+    <!-- 上传附件 -->
+    <tenant-upload
+      ref="upload"
+      :dialog-visible="dialogUpload.isVisible"
+      :title="dialogUpload.title"
+      @close="editUploadClose"
+      @success="editUploadSuccess"
+    />
     <el-dialog
     <el-dialog
       v-el-drag-dialog
       v-el-drag-dialog
       :close-on-click-modal="false"
       :close-on-click-modal="false"
@@ -220,6 +230,7 @@
 	import Pagination2 from "@/components/Pagination"
 	import Pagination2 from "@/components/Pagination"
 	import TenantEdit from "./components/Edit"
 	import TenantEdit from "./components/Edit"
 	import TenantView from "./components/View"
 	import TenantView from "./components/View"
+  import TenantUpload from "./components/Upload"
 	// 【程序中心】-API
 	// 【程序中心】-API
 	import programCenterApi from "@/api/resourceProductMgr/programCenter"
 	import programCenterApi from "@/api/resourceProductMgr/programCenter"
 	// 【设备管理】-API
 	// 【设备管理】-API
@@ -230,7 +241,7 @@
 	export default {
 	export default {
 	  name: "WarehouseTypeMgr",
 	  name: "WarehouseTypeMgr",
 	  directives: { elDragDialog },
 	  directives: { elDragDialog },
-	  components: { Pagination, Pagination2, TenantEdit, TenantView },
+	  components: { Pagination, Pagination2, TenantEdit, TenantView,TenantUpload },
 	  props: {
 	  props: {
 	  },
 	  },
 	  data () {
 	  data () {
@@ -244,6 +255,10 @@
 	        isVisible: false,
 	        isVisible: false,
 	        context: ''
 	        context: ''
 	      },
 	      },
+        dialogUpload: {
+          isVisible: false,
+          title: ""
+        },
 	      tenantViewVisible: false,
 	      tenantViewVisible: false,
 	      tableKey: 0,
 	      tableKey: 0,
 	      queryParams: initQueryParams({}),
 	      queryParams: initQueryParams({}),
@@ -314,6 +329,24 @@
 	  			}
 	  			}
 	  		})
 	  		})
 	  	},
 	  	},
+
+
+      // 上传框弹出
+      editUpload(){
+        if (this.selection.length!=1) {
+          this.$message({
+            message: this.$t("tips.mustOne"),
+            type: "warning"
+          })
+          return
+        }
+        let row = this.selection[0];
+        this.$refs.upload.setTenant(row, this.dicts)
+        this.$refs.upload.type = "upload"
+        this.dialogUpload.title = this.$t("resource.buttons.upload")
+        this.dialogUpload.isVisible = true
+
+      },
 	  	// 【从设备删除】按钮-事件
 	  	// 【从设备删除】按钮-事件
 	  	equipmentDelete(row){
 	  	equipmentDelete(row){
 	  		this.$confirm(this.$t("resource.tips.deletePg"), this.$t("common.tips"), {
 	  		this.$confirm(this.$t("resource.tips.deletePg"), this.$t("common.tips"), {
@@ -372,9 +405,16 @@
 	    editClose () {
 	    editClose () {
 	      this.dialog.isVisible = false
 	      this.dialog.isVisible = false
 	    },
 	    },
+      editUploadClose (){
+        this.dialogUpload.isVisible = false
+      },
 	    editSuccess () {
 	    editSuccess () {
 	      this.search()
 	      this.search()
 	    },
 	    },
+      editUploadSuccess(){
+        this.search()
+      },
+
 	    // 当选择项发生变化时会触发该事件
 	    // 当选择项发生变化时会触发该事件
 	    onSelectChange (selection) {
 	    onSelectChange (selection) {
 	    	// console.log("当选择项发生变化时会触发该事件:", this.selection)
 	    	// console.log("当选择项发生变化时会触发该事件:", this.selection)

+ 356 - 0
imcs-ui/src/views/zuihou/resourceProductMgr/equipmentProgramMgr/components/Upload.vue

@@ -0,0 +1,356 @@
+<template>
+  <el-dialog
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :title="title"
+    :append-to-body="true"
+    :visible.sync="isVisible"
+    :width="width"
+    top="50px"
+  >
+    <el-form ref="form" :model="tenant" :disabled="formDisabled" :rules="rules" label-position="right" label-width="130px">
+      <el-form-item :label='$t("resource.form.target_resource")+":"' prop="no">
+        <el-input v-model="tenant.no"  readonly="readonly" />
+      </el-form-item>
+      <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=".txt"
+          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>
+    <div slot="footer" class="dialog-footer">
+      <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
+      <el-button plain type="primary" :disabled="confirmDisabled" @click="submitForm">{{ $t('common.confirm') }}</el-button>
+    </div>
+  </el-dialog>
+</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: {
+      dialogVisible: {
+        type: Boolean,
+        default: false
+      },
+      title: {
+        type: String,
+        default: ''
+      }
+    },
+    data () {
+      return {
+        formDisabled: false,
+        tableData: [],
+        eqList: [], // 设备下拉类别数据
+        toolList: [], // 刀具列表
+        pgContent: '',  // 程序内容
+        type: 'add',
+        tenant: this.initTenant(),
+        screenWidth: 0,
+        width: this.initWidth(),
+        confirmDisabled: false,
+        dicts:{
+          NATION: {}
+        },
+        // 附件上传
+        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'}
+      */],
+        roles: [],
+        rules: {
+          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() {
+      // 加载【设备】列表数据
+      this.equmentList()
+    },
+    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
+          // 查询【程序】信息
+          this.getProgram(response.data.filename)
+        }
+      },
+      // 文件上传失败时的钩子
+      handleError(err, file, fileList){
+        console.log("文件上传失败~", err)
+      },
+      // 文件上传时的钩子
+      handlePropress(event, file, fileList){
+        console.log("文件上传~", event)
+      },
+      initTenant () {
+        return {
+          id: '',
+          no: '',
+          name: '',
+          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, dicts) {
+        if(val){
+          this.tenant = { ...val }
+          //赋值
+          this.tenant.no = val.name
+          // 如果附件存在 /
+          if(!!val.filePath){
+            let arr = val.filePath.split("/");
+            // 查询【程序】信息
+            this.getProgram(arr[arr.length -1])
+          }
+        }
+        // 字典表
+        this.dicts = dicts
+      },
+      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)
+          // return false
+          if (valid) {
+            this.confirmDisabled = true
+            if (this.type === 'add') {
+              this.save()
+            } else {
+              this.update()
+            }
+          } else {
+            return false
+          }
+        })
+      },
+      save () {
+        programCenterApi.save(this.tenant)
+          .then((response) => {
+            const res = response.data
+            if (res.isSuccess) {
+              this.isVisible = false
+              this.$message({
+                message: this.$t('tips.createSuccess'),
+                type: 'success'
+              })
+              // 通知列表
+              this.$emit("success");
+              // 通知列表-并关闭弹出框
+              this.$emit("close");
+            }
+          }).finally(() => {
+          this.confirmDisabled = false
+          return true
+        })
+      },
+      update () {
+        programCenterApi.update(this.tenant)
+          .then((response) => {
+            const res = response.data
+            if (res.isSuccess) {
+              this.isVisible = false
+              this.$message({
+                message: this.$t('tips.updateSuccess'),
+                type: 'success'
+              })
+              // 通知列表
+              this.$emit("success");
+              // 通知列表-并关闭弹出框
+              this.$emit("close");
+            }
+          }).finally(() => {
+          this.confirmDisabled = false
+          return true
+        })
+      },
+      // 【设备】下拉数据
+      equmentList() {
+        productionResourcesMgrApi.getList({cncProgram: '1'}).then(res => {
+          res = res.data
+          // console.log("【设备】下拉数据:", res)
+          if(res.isSuccess){
+            this.eqList = res.data
+          }
+        })
+      },
+      // 根据[文件名]获取文件内容
+      getProgram(fileName){
+        programCenterApi.getUploadFile({fileName: fileName}).then(res => {
+          res = res.data
+          console.log("根据[文件名]:", res)
+          if(res.isSuccess){
+            const obj = res.data
+            // [运行时间]字段的值
+            this.tenant.runTime = obj.runTime
+            // [程序内容]字段的值
+            this.pgContent = obj.content
+            // [刀具]列表
+            this.toolList = obj.toolList
+            // 附件数据
+            this.fileList = [{
+              name: obj.name,
+              url: obj.url
+            }]
+          }
+        })
+      }
+
+    }
+  }
+</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>