Forráskód Böngészése

opc位置增加图片

hfxc226 2 éve
szülő
commit
876404f708

+ 9 - 0
src/api/upms/file.js

@@ -51,6 +51,15 @@ export function uploadFileSpare (parameter) {
   })
 }
 
+export function uploadImgPosition (parameter) {
+  return axios({
+    url: `/upms/files/upload/position`,
+    method: 'POST',
+    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+    data: parameter
+  })
+}
+
 export function downloadFile (url) {
   const storeToken = Vue.ls.get(ACCESS_TOKEN)
   request.post(process.env.VUE_APP_API_BASE_URL + url, null, {

+ 95 - 0
src/components/Upload/UploadPositionImg.vue

@@ -0,0 +1,95 @@
+<template>
+  <div class="clearfix">
+    <a-upload
+      :action="action"
+      listType="picture-card"
+      :fileList="fileList"
+      @change="handleChange"
+      :customRequest="customRequest"
+      :remove="handleRemove"
+      :beforeUpload="beforeUpload"
+    >
+      <div v-if="fileList.length < maxSize">
+        <a-icon type="plus" />
+        <div class="ant-upload-text">Upload</div>
+      </div>
+    </a-upload>
+    <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel" :width="1200">
+      <img style="width: 100%" :src="previewImage" />
+    </a-modal>
+  </div>
+</template>
+
+<script>
+import { uploadImgPosition } from '@/api/upms/file'
+export default {
+  name: 'UploadPositionImg',
+  data () {
+    return {
+      previewVisible: false,
+      action: '/upms/files/upload/position',
+      maxSize: 1,
+      previewImage: '',
+      fileList: []
+    }
+  },
+  methods: {
+    base (maxSize, fileList) {
+      this.fileList = fileList
+      this.maxSize = maxSize
+    },
+    handleCancel () {
+      this.previewVisible = false
+    },
+    handlePreview (file) {
+      this.previewImage = file.url || file.thumbUrl
+      this.previewVisible = true
+    },
+    handleChange ({ fileList }) {
+      // this.fileList = fileList
+      // this.$emit('catchImage', fileList)
+    },
+    async customRequest (data) {
+      const formData = new FormData()
+      formData.append('file', data.file)
+      data.onProgress()
+      const that = this
+      uploadImgPosition(formData).then(res => {
+        data.onSuccess()
+        that.fileList.push({
+          uid: '-1',
+          name: res.data.fileName,
+          status: 'done',
+          url: this.BaseTool.Constant.FILE_URL + res.data.url
+        })
+        this.$emit('catchImage', that.fileList)
+      })
+    },
+    handleRemove (file) {
+      const index = this.fileList.indexOf(file)
+      const newFileList = this.fileList.slice()
+      newFileList.splice(index, 1)
+      this.fileList = newFileList
+      this.$emit('catchImage', this.fileList)
+      return true
+    },
+    beforeUpload (file, fileList) {
+    }
+  }
+}
+</script>
+<style>
+  /* you can make up upload button and sample style by using stylesheets */
+  .ant-upload-select-picture-card i {
+    font-size: 32px;
+    color: #999;
+  }
+
+  .ant-upload-select-picture-card .ant-upload-text {
+    margin-top: 8px;
+    color: #666;
+  }
+  .ant-upload-btn {
+    margin-top: 20px;
+  }
+</style>

+ 1 - 1
src/utils/tool.js

@@ -38,7 +38,7 @@ BaseTool.Constant = {
   INVEST: 'INVEST',
   FINANCE: 'FINANCE',
   FINANCING: 'FINANCING',
-  FILE_URL: 'http://sb.pc.litian2017.com',
+  FILE_URL: '',
   HOST: window.location.protocol + '//' + window.location.host,
   scrollY: document.documentElement.clientHeight < 680 ? document.documentElement.clientHeight * 0.4 : document.documentElement.clientHeight * 0.5
 }

+ 14 - 0
src/views/sb/position/SbPosition.vue

@@ -8,6 +8,18 @@
               <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/编码"/>
             </a-form-item>
           </a-col>
+          <a-col :md="8" :sm="24">
+            <a-form-item label="是否OPC展示">
+              <a-select v-model="queryParam.opcFlag" placeholder="请选择">
+                <a-select-option
+                  v-for="(label,value) in yesNoMap"
+                  :key="value"
+                  :label="label"
+                  :value="parseInt(value)">{{ label }}
+                </a-select-option>
+              </a-select>
+            </a-form-item>
+          </a-col>
           <a-col :md="8" :sm="24">
             <a-form-item label="上层位置类型">
               <a-tree-select
@@ -98,6 +110,7 @@ export default {
   data () {
     return {
       // 查询参数
+      yesNoMap: {},
       queryParam: {
       },
       positionTypeMap: {},
@@ -194,6 +207,7 @@ export default {
   created () {
     this.tableOption()
     this.delFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DELFLAG)
+    this.yesNoMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
     this.positionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBPOSITION_TYPE)
   },
   methods: {

+ 29 - 11
src/views/sb/position/modules/BaseForm.vue

@@ -58,7 +58,7 @@
         >
         </a-tree-select>
       </a-form-item>
-<!--      <a-form-item
+      <!--      <a-form-item
         label="父子关联编码"
         :labelCol="BaseTool.Constant.labelCol"
         :wrapperCol="BaseTool.Constant.wrapperCol"
@@ -90,16 +90,30 @@
           :min="1"
           v-decorator="['sort', {initialValue:1,rules: [{required: true, message: '排序不能为空'}]}]" />
       </a-form-item>
+      <a-form-item
+        label="是否OPC展示"
+        :labelCol="BaseTool.Constant.labelCol"
+        :wrapperCol="BaseTool.Constant.wrapperCol"
+      >
+        <a-select v-decorator="['opcFlag', {initialValue:DictCache.VALUE.DELFLAG.NORMAL, rules: [{required: true, message: '是否OPC展示不能为空'}]}]" placeholder="请选择">
+          <a-select-option
+            v-for="(label,value) in yesNoMap"
+            :key="value"
+            :label="label"
+            :value="parseInt(value)">{{ label }}
+          </a-select-option>
+        </a-select>
+      </a-form-item>
       <row-item>
         <a-form-item
           label="图片"
           :labelCol="BaseTool.Constant.labelCol"
           :wrapperCol="BaseTool.Constant.wrapperCol"
         >
-          <upload-spare-file
+          <upload-position-img
             ref="imageUpload"
             @catchImage="catchImage"
-          ></upload-spare-file>
+          ></upload-position-img>
         </a-form-item>
       </row-item>
       <a-form-item
@@ -135,19 +149,21 @@
 import pick from 'lodash.pick'
 import { addSbPosition, updateSbPosition, getSbPositionTree } from '@/api/sb/position'
 import { queryRepairUser } from '@/api/upms/user-dept'
-
+import UploadPositionImg from '@/components/Upload/UploadPositionImg'
 export default {
   name: 'BaseSbPosition',
+  components: { UploadPositionImg },
   data () {
     return {
       confirmLoading: false,
       modalTitle: null,
       form: this.$form.createForm(this),
       visible: false,
-      img: '',
+      opcImg: '',
       positionTypeMap: {},
       delFlagMap: {},
       userList: {},
+      yesNoMap: {},
       treeData: []
     }
   },
@@ -155,6 +171,7 @@ export default {
   },
   created () {
     this.delFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DELFLAG)
+    this.yesNoMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
     this.positionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBPOSITION_TYPE)
     const params = { roleType: 3, deptId: null, queryType: 1 }
     queryRepairUser(params).then(res => {
@@ -183,28 +200,29 @@ export default {
           'type',
           'code',
           'sort',
+          'opcFlag',
           'delFlag',
           'parentId',
           'userId',
           'remark'
         ])))
       })
-      this.img = record.img
+      this.opcImg = record.opcImg
       const fileList = []
-      if (record.img) {
+      if (record.opcImg) {
         fileList.push({
           uid: '-1',
           name: record.name,
           status: 'done',
-          url: this.BaseTool.Constant.FILE_URL + record.img,
-          originUrl: record.img
+          url: this.BaseTool.Constant.FILE_URL + record.opcImg,
+          originUrl: record.opcImg
         })
       }
       this.$refs.imageUpload.base(1, fileList)
     },
     catchImage (fileList) {
       if (fileList.length !== 0) {
-        this.img = fileList[0].url
+        this.opcImg = fileList[0].url
       }
     },
     save () {
@@ -215,7 +233,7 @@ export default {
           this.confirmLoading = false
           return
         }
-        values.img = this.img
+        values.opcImg = this.opcImg
         if (this.BaseTool.String.isBlank(values.id)) {
           addSbPosition(values)
             .then(() => {

+ 6 - 2
src/views/sb/position/modules/Detail.vue

@@ -14,8 +14,9 @@
       <detail-list-item term="排序">{{ model.sort }}</detail-list-item>
       <detail-list-item term="上层位置">{{ model.parentName }}</detail-list-item>
       <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
-      <detail-list-item term="图片"><img :src="BaseTool.Constant.FILE_URL + model.img" width="200px" height="200px"/></detail-list-item>
+      <detail-list-item term="图片"><img :src="BaseTool.Constant.FILE_URL + model.opcImg" width="200px" height="200px"/></detail-list-item>
       <detail-list-item term="创建人">{{ model.createdUserName }}</detail-list-item>
+      <detail-list-item term="是否OPC展示"><badge :status="DictCache.COLOR.DELFLAG[model.opcFlag]" :text="yesNoMap[model.opcFlag]"></badge></detail-list-item>
       <detail-list-item term="是否删除"><badge :status="DictCache.COLOR.DELFLAG[model.delFlag]" :text="delFlagMap[model.delFlag]"></badge></detail-list-item>
       <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>
     </detail-list>
@@ -46,7 +47,8 @@ export default {
         'id': null,
         'no': null,
         'name': null,
-        'img': null,
+        'opcFlag': null,
+        'opcImg': null,
         'type': null,
         'sort': null,
         'delFlag': null,
@@ -58,11 +60,13 @@ export default {
         'createdUserName': null
       },
       positionTypeMap: {},
+      yesNoMap: {},
       delFlagMap: {}
     }
   },
   created () {
     this.delFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DELFLAG)
+    this.yesNoMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
     this.positionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBPOSITION_TYPE)
   },
   methods: {