浏览代码

物料池定版

朱鑫波 4 年之前
父节点
当前提交
217e59914d

+ 114 - 81
src/views/modules/autoLaunch/application/components/creatApplication.vue

@@ -133,15 +133,16 @@
             v-if="uploadType == '1'"
             :labelCol="{ xs: { span: 24 }, sm: { span: 5 } }"
             :wrapperCol="{ xs: { span: 24 }, sm: { span: 16 } }"
-            class="require-class"
+            class="require-class fileUpload"
+            id="fileUpload"
           >
             <!-- <a-upload name="file" :file-list="fileList" :before-upload="beforeUpload" @change="handleChange">
               <a-button><a-icon type="upload" />文件上传</a-button>
             </a-upload> -->
+            <!-- :action="uploadAction" -->
             <a-upload
               name="file"
               :multiple="false"
-              :action="uploadAction"
               :headers="tokenHeader"
               :file-list="fileList"
               :showUploadList="false"
@@ -166,7 +167,7 @@
               v-decorator="[
                 'appVersion',
                 {
-                  rules: [{ required: true, message: '请填写应用标记' }, { validator: checkAppVersion }],
+                  rules: [{ required: true, message: ' ' }, { validator: checkAppVersion }],
                 },
               ]"
               placeholder="请填写应用标记,必填且不可重复,如快手-5.6.1.66"
@@ -200,7 +201,7 @@
               v-decorator="[
                 'useSdk',
                 {
-                  rules: [{ required: true, message: '安卓应用已接入快手广告监测SDK必选' }],
+                  rules: [{ message: '安卓应用已接入快手广告监测SDK必选' }],
                 },
               ]"
             >
@@ -230,7 +231,7 @@
             :wrapperCol="{ xs: { span: 24 }, sm: { span: 16 } }"
             v-if="uploadType == '2' && appType == 'android'"
           >
-            <a-input v-decorator="['trackUrl', { validator: handleConfirmValue }]" placeholder="请填写监测链接" />
+            <a-input v-decorator="['trackUrl']" placeholder="请填写监测链接" />
           </a-form-item>
         </a-form>
       </a-card>
@@ -246,6 +247,7 @@ import uploadFile from './uploadFile.vue'
 import { mapActions, mapGetters } from 'vuex'
 import BMF from 'browser-md5-file'
 import selectTable from '@/views/modules/Statistics/components/selectPagination.vue'
+import $ from 'jquery'
 const fileSuffix = ['xlsx', 'xls', 'zip']
 export default {
   name: 'BaseForm',
@@ -290,29 +292,32 @@ export default {
       application: false,
       confirmLoading: false,
       imageToken: '',
-      uploadAction: '/kuaishouAppPackage/importAppExcel',
+      // uploadAction: '/kuaishouAppPackage/importAppExcel',
       tokenHeader: { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) },
       okCreated: false,
+      dataFile: null,
     }
   },
   methods: {
     checkAppVersion(rule, value, callback) {
       if (value != '') {
-        let params = {}
-        params.projectId = this.projectId
-        params.appVersion = value
-        getAction('/kuaishouAppPackage/checkAppVersion', params).then((res) => {
-          if (res.success) {
-            callback()
-          } else {
-            callback(res.message)
-          }
-        })
+        if (this.projectId) {
+          let params = {}
+          params.projectId = this.projectId
+          params.appVersion = value
+          getAction('/kuaishouAppPackage/checkAppVersion', params).then((res) => {
+            if (res.success) {
+              callback()
+            } else {
+              callback(res.message)
+            }
+          })
+        }
+      } else {
+        callback('应用标记必填')
       }
     },
-    overUpload(file) {
-      console.log(file)
-    },
+    overUpload(file) {},
     downLoadFile() {
       downFile('/kuaishouAppPackage/exportAppTemplate').then((res) => {
         let blob = new Blob([res], {
@@ -329,64 +334,66 @@ export default {
       })
     },
     handleChange(info) {
-      let fileList = [...info.fileList]
+      // let fileList = [...info.fileList]
 
-      // 1. Limit the number of uploaded files
-      //    Only to show two recent uploaded files, and old ones will be replaced by the new
-      fileList = fileList.slice(-2)
+      // // 1. Limit the number of uploaded files
+      // //    Only to show two recent uploaded files, and old ones will be replaced by the new
+      // fileList = fileList.slice(-2)
 
-      // 2. read from response and show file link
-      fileList = fileList.map((file) => {
-        if (file.response) {
-          // Component will show file.url as link
-          file.url = file.response.url
-        }
-        return file
-      })
-      if (fileList.length > 0) {
-        this.fileList = [
-          {
-            ...fileList[fileList.length - 1],
-          },
-        ]
-      } else {
-        this.fileList = []
-      }
-      // this.loadDisabled = false
-      // this.$message.success('文件导入成功,异步创建中,请稍后查看...')
-      if (info.file.status !== 'uploading') {
-        console.log(info.file, info.fileList)
-      }
-      if (info.file.status === 'done') {
-        this.loadDisabled = false
-        if (info.file.response.code == 200) {
-          // this.application = true
-          // this.$emit('getDataList')
-          this.okCreated = true
-          this.$message.success(info.file.response.message)
-        } else {
-          this.okCreated = false
-          this.$message.error(info.file.response.message)
-        }
-      } else if (info.file.status === 'error') {
-        this.$message.error(`${info.file.name}上传失败`)
-        this.loadDisabled = false
-      }
+      // // 2. read from response and show file link
+      // fileList = fileList.map((file) => {
+      //   if (file.response) {
+      //     // Component will show file.url as link
+      //     file.url = file.response.url
+      //   }
+      //   return file
+      // })
+      // if (fileList.length > 0) {
+      //   this.fileList = [
+      //     {
+      //       ...fileList[fileList.length - 1],
+      //     },
+      //   ]
+      // } else {
+      //   this.fileList = []
+      // }
+      this.loadDisabled = false
+      this.$message.success('文件导入成功')
+      // if (info.file.status !== 'uploading') {
+      //   console.log(info.file, info.fileList)
+      // }
+      // if (info.file.status === 'done') {
+      //   this.loadDisabled = false
+      //   if (info.file.response.code == 200) {
+      //     // this.application = true
+      //     // this.$emit('getDataList')
+      //     this.okCreated = true
+      //     this.$message.success(info.file.response.message)
+      //   } else {
+      //     this.okCreated = false
+      //     this.$message.error(info.file.response.message)
+      //   }
+      // } else if (info.file.status === 'error') {
+      //   this.$message.error(`${info.file.name}上传失败`)
+      //   this.loadDisabled = false
+      // }
 
       // console.log(this.form)
     },
     beforeUpload(file) {
       // this.cosUpload(file)
-      if (process.env.NODE_ENV == 'development') {
-        this.uploadAction = `/jeecg-boot/kuaishouAppPackage/importAppExcel?projectId=${this.projectId}&platform=${
-          this.appType == 'ios' ? +this.platform + 2 : +this.platform
-        }&imageUrl=${this.fileUrl}`
-      } else if (process.env.NODE_ENV == 'debug') {
-      } else if (process.env.NODE_ENV == 'production') {
-        this.uploadAction = `${this.axios.defaults.baseURL}/kuaishouAppPackage/importAppExcel?projectId=${
-          this.projectId
-        }&platform=${this.appType == 'ios' ? +this.platform + 2 : +this.platform}&imageUrl=${this.fileUrl}`
-      }
+      // if (process.env.NODE_ENV == 'development') {
+      //   this.uploadAction = `/jeecg-boot/kuaishouAppPackage/importAppExcel?projectId=${this.projectId}&platform=${
+      //     this.appType == 'ios' ? +this.platform + 2 : +this.platform
+      //   }&imageUrl=${this.fileUrl}`
+      // } else if (process.env.NODE_ENV == 'debug') {
+      // } else if (process.env.NODE_ENV == 'production') {
+      //   this.uploadAction = `${this.axios.defaults.baseURL}/kuaishouAppPackage/importAppExcel?projectId=${
+      //     this.projectId
+      //   }&platform=${this.appType == 'ios' ? +this.platform + 2 : +this.platform}&imageUrl=${this.fileUrl}`
+      // }
+      // this.dataFile = file
+      this.dataFile = $('.fileUpload').eq(0).find('input')[0].files[0]
       this.loadDisabled = true
       const size = (Number(file.size) / (1024 * 1024)).toFixed(2)
       const fileName = file.name
@@ -493,6 +500,9 @@ export default {
       this.handleSubmit()
     },
     handleCancel() {
+      this.dataFile = null
+      this.appType = 'android'
+      this.okCreated = false
       this.form.resetFields()
       this.fileUrl = ''
       this.projectId = undefined
@@ -555,36 +565,61 @@ export default {
       //   console.log('文件地址:' + this.file)
       //   console.log('图片地址:' + this.imageUrl)
       //   e.preventDefault()
-      
+
       this.form.validateFields((err, values) => {
         if (!err) {
           if (this.fileUrl && this.projectId) {
+            this.confirmLoading = true
             let params = {}
             params.projectId = this.projectId
             if (this.uploadType == '1') {
+              // var file = document.getElementById('fileId').files[0] //获取文件流
               this.url.insertTemplateUrl = '/kuaishouAppPackage/importAppExcel'
               params.platform = this.appType == 'ios' ? +this.platform + 2 : +this.platform
               params.imageUrl = this.fileUrl
-              if (this.okCreated) {
-                this.okCreated = false
-                this.$message.success('创建成功')
-                this.handleCancel()
-                this.$emit('getDataList')
+              if (this.dataFile) {
+                let formData = new FormData()
+                formData.append('file', this.dataFile)
+                formData.append('projectId', this.projectId)
+                formData.append('platform', this.appType == 'ios' ? +this.platform + 2 : +this.platform)
+                formData.append('imageUrl', this.fileUrl)
+                // if (process.env.NODE_ENV == 'development') {
+                //   this.uploadAction = `/jeecg-boot/kuaishouAppPackage/importAppExcel?projectId=${
+                //     this.projectId
+                //   }&platform=${this.appType == 'ios' ? +this.platform + 2 : +this.platform}&imageUrl=${this.fileUrl}`
+                // } else if (process.env.NODE_ENV == 'debug') {
+                // } else if (process.env.NODE_ENV == 'production') {
+                //   this.uploadAction = `${this.axios.defaults.baseURL}/kuaishouAppPackage/importAppExcel?projectId=${
+                //     this.projectId
+                //   }&platform=${this.appType == 'ios' ? +this.platform + 2 : +this.platform}&imageUrl=${this.fileUrl}`
+                // }
+
+                postAction('/kuaishouAppPackage/importAppExcel', formData).then((res) => {
+                  this.confirmLoading = false
+                  if (res.code === 200) {
+                    this.$message.success('创建成功')
+                    this.handleCancel()
+                    this.$emit('getDataList')
+                  } else {
+                    this.$message.error(res.message)
+                  }
+                })
               } else {
-                this.$message.error('excel文件有误,请重新上传后点击')
+                this.$message.error('请上传文件')
               }
 
               return
             } else {
               this.url.insertTemplateUrl = '/kuaishouAppPackage/fillInLink'
               params = { ...values }
-              params.useSdk = params.useSdk?params.useSdk.length > 0 ? 1 : 0:null
+              params.useSdk = params.useSdk ? (params.useSdk.length > 0 ? 1 : 0) : null
               params.projectId = this.projectId
               params.appIconUrl = this.fileUrl
               params.platform = this.appType == 'ios' ? +this.platform + 2 : +this.platform
             }
 
             postAction(this.url.insertTemplateUrl, params).then((res) => {
+              this.confirmLoading = false
               if (res.success) {
                 this.$message.success('创建成功')
                 this.handleCancel()
@@ -600,9 +635,7 @@ export default {
       })
     },
 
-    onChange(value) {
-      console.log(value)
-    },
+    onChange(value) {},
   },
   created: function () {
     let params = {}

+ 39 - 80
src/views/modules/autoLaunch/application/components/editApplication.vue

@@ -166,7 +166,7 @@
               v-decorator="[
                 'appVersion',
                 {
-                  rules: [{ required: true, message: '请填写应用标记' }, { validator: checkAppVersion }],
+                  rules: [{ required: true, message: ' ' }, { validator: checkAppVersion }],
                 },
               ]"
               placeholder="请填写应用标记,必填且不可重复,如快手-5.6.1.66"
@@ -184,14 +184,7 @@
             :wrapperCol="{ xs: { span: 24 }, sm: { span: 16 }, offset: 5 }"
             v-if="uploadType == '2' && appType == 'android'"
           >
-            <a-checkbox-group
-              v-decorator="[
-                'useSdk',
-                {
-                  rules: [{ required: true, message: '安卓应用已接入快手广告监测SDK必选' }],
-                },
-              ]"
-            >
+            <a-checkbox-group v-decorator="['useSdk']">
               <a-checkbox :value="0"> 该应用已接入快手广告监测SDK </a-checkbox>
             </a-checkbox-group>
           </a-form-item>
@@ -218,15 +211,7 @@
             :wrapperCol="{ xs: { span: 24 }, sm: { span: 16 } }"
             v-if="uploadType == '2' && appType == 'android'"
           >
-            <a-input
-              v-decorator="[
-                'trackUrl',
-                {
-                  rules: [{ validator: handleConfirmValue }],
-                },
-              ]"
-              placeholder="请填写监测链接"
-            />
+            <a-input v-decorator="['trackUrl']" placeholder="请填写监测链接" />
           </a-form-item>
         </a-form>
       </a-card>
@@ -294,17 +279,20 @@ export default {
   methods: {
     checkAppVersion(rule, value, callback) {
       if (value != '') {
-        let params = {}
-        params.projectId = this.projectId
-        params.appVersion = value
-        params.id = this.appId
-        getAction('/kuaishouAppPackage/checkAppVersion', params).then((res) => {
-          if (res.success) {
-            callback()
-          } else {
-            callback(res.message)
-          }
-        })
+        if (this.projectId) {
+          let params = {}
+          params.projectId = this.projectId
+          params.appVersion = value
+          getAction('/kuaishouAppPackage/checkAppVersion', params).then((res) => {
+            if (res.success) {
+              callback()
+            } else {
+              callback(res.message)
+            }
+          })
+        }
+      } else {
+        callback('应用标记必填')
       }
     },
     overUpload(file) {
@@ -504,30 +492,25 @@ export default {
         if (res.success) {
           this.fileUrl = res.result.appIconUrl
           this.appType = res.result.platform > 2 ? 'ios' : 'android'
-          res.result.platform = res.result.platform > 2 ? res.result.platform - 2 + '' : res.result.platform + ''
+          this.platform = res.result.platform > 2 ? res.result.platform - 2 + '' : res.result.platform + ''
           res.result.useSdk = res.result.useSdk ? (res.result.useSdk == 0 ? [] : [0]) : null
           this.projectId = res.result.projectId
           if (this.appType == 'android') {
             this.$nextTick(() => {
               this.form.setFieldsValue(
-                pick(
-                  res.result,
-                  'url',
-                  'appVersion',
-                  'packageName',
-                  'platform',
-                  'appPrivacyUrl',
-                  'useSdk',
-                  'trackUrl',
-                  'appName',
-                  'projectName'
-                )
+                pick(res.result, 'url', 'packageName', 'appPrivacyUrl', 'useSdk', 'trackUrl', 'appName', 'projectName')
               )
+              setTimeout(() => {
+                this.form.setFieldsValue(pick(res.result, 'appVersion'))
+              }, 150)
             })
           } else {
             setTimeout(() => {
-              this.form.setFieldsValue(pick(res.result, 'url', 'appVersion', 'platform', 'appName', 'projectName'))
+              this.form.setFieldsValue(pick(res.result, 'url', 'appVersion', 'projectName'))
             }, 100)
+            setTimeout(() => {
+              this.form.setFieldsValue(pick(res.result, 'appName'))
+            }, 150)
           }
         }
       })
@@ -541,40 +524,17 @@ export default {
     },
     ...mapGetters(['nickname', 'avatar', 'userInfo']),
     changePlatform() {
-      this.form.resetFields()
-      if (this.appType == 'android') {
-        this.showAndroid = true
-        this.showIOS = false
-        this.platform = '1'
-      } else {
-        this.showAndroid = false
-        this.showIOS = true
-        this.showDownLoad = true
-        this.platform = '1'
-      }
-    },
-    changeShowUpload() {
-      this.form.resetFields()
-      if (this.uploadType == '1') {
-        this.showUploadFile = true
-        this.showDownLoad = false
-      } else {
-        this.showUploadFile = false
-        this.showDownLoad = true
-      }
-    },
-    changeShowUploadType() {
-      this.form.resetFields()
-      if (this.platform == '2') {
-        this.showUpload = false
-        this.showUploadFile = false
-        this.showDownLoad = true
-        this.uploadType = '1'
-      } else {
-        this.showUpload = true
-        this.showUploadFile = true
-        this.showDownLoad = false
-      }
+      // this.form.resetFields()
+      // if (this.appType == 'android') {
+      //   this.showAndroid = true
+      //   this.showIOS = false
+      //   this.platform = '1'
+      // } else {
+      //   this.showAndroid = false
+      //   this.showIOS = true
+      //   this.showDownLoad = true
+      //   this.platform = '1'
+      // }
     },
 
     handleSubmit() {
@@ -588,9 +548,9 @@ export default {
       //   console.log('图片地址:' + this.imageUrl)
       //   e.preventDefault()
       this.form.validateFields((err, values) => {
-        console.log('Received values of form: ', values)
         if (!err) {
           if (this.fileUrl && this.projectId) {
+            this.confirmLoading = true
             let params = {}
             params.projectId = this.projectId
             if (this.uploadType == '1') {
@@ -606,9 +566,8 @@ export default {
               params.appIconUrl = this.fileUrl
               params.platform = this.appType == 'ios' ? +this.platform + 2 : +this.platform
             }
-
-            console.log(params)
             postAction(this.url.insertTemplateUrl, params).then((res) => {
+              this.confirmLoading = false
               if (res.success) {
                 this.$message.success('修改成功')
                 this.handleCancel()

+ 9 - 9
src/views/modules/autoLaunch/application/components/uploadFile.vue

@@ -156,17 +156,17 @@ export default {
                 }
               })
             } else {
-              if (n == '') {
+              if (n === '') {
                 this.fileList = []
               } else {
-                this.fileList = [
-                  {
-                    uid: 1,
-                    name: 1,
-                    status: 'done',
-                    url: n,
-                  },
-                ]
+                this.fileList = []
+                var data = {
+                  uid: 1,
+                  name: '回显',
+                  status: 'done',
+                  url: n,
+                }
+                this.fileList.push(data)
               }
             }
           } else {

+ 2 - 2
vue.config.js

@@ -77,7 +77,7 @@ module.exports = {
         // target: 'http://192.168.1.43:8088', //请求本地 需要jeecg-boot后台项目  毕洁泉
         // target: 'http://192.168.1.43:8806', //请求本地 需要jeecg-boot后台项目  毕洁泉
         // target: 'http://192.168.0.252:8098', //请求本地 需要jeecg-boot后台项目  毕洁泉
-        target: 'http://192.168.1.219:8081', //请求本地 需要jeecg-boot后台项目  赵西安
+        // target: 'http://192.168.1.219:8081', //请求本地 需要jeecg-boot后台项目  赵西安
         // target: 'http://192.168.1.193:8080', //请求本地 需要jeecg-boot后台项目  李煜一
         // target: 'http://192.168.1.193:31012', //请求本地 需要jeecg-boot后台项目  李煜一
         //  target: 'http://api.tjyourong.com.cn', //请求本地 需要jeecg-boot后台项目
@@ -86,7 +86,7 @@ module.exports = {
         //  target: 'http://adsp.tjyourong.com.cn/', //请求本地 需要jeecg-boot后台项目
         // target: 'http://192.168.1.251/', //请求本地 需要jeecg-boot后台项目 
         // target:'http://118.24.244.213:8804',
-      //  target:'http://139.186.165.84:8806', //测试
+       target:'http://139.186.165.84:8806', //测试
 
         ws: false,