newAppId.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="newAppId">
  3. <div class="moduler">
  4. <div class="moduler-title">选择账户</div>
  5. <div>
  6. <div class="row-item">
  7. <div class="hint-item"></div>
  8. <div class="label-item">
  9. <div class="text-item">账户</div>
  10. <div class="required-item"></div>
  11. </div>
  12. <div class="input-item">
  13. <!-- <Treeselect :appId.sync="accountId" :multiple="false" request="2" reqUrl='/ctop/projectMember/getProjectAccountByUserId' ref="treeSelect" style="margin-bottom:8px;width:580px " /> -->
  14. <Treeselect :appId.sync="accountId" :multiple="false" request="2,4" ref="treeSelect" style="margin-bottom:8px;width:600px " />
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. <!-- 基础信息 -->
  20. <div class="moduler">
  21. <div class="moduler-title">应用信息</div>
  22. <div class="row-item">
  23. <div class="hint-item"></div>
  24. <div class="label-item">
  25. <div class="text-item">操作系统</div>
  26. <div class="required-item"></div>
  27. </div>
  28. <div class="input-item">
  29. <a-form-item>
  30. <a-radio-group v-model="platform" >
  31. <a-radio-button :value="1">Android应用刚下载</a-radio-button>
  32. <a-radio-button :value="3">IOS应用下载</a-radio-button>
  33. </a-radio-group>
  34. </a-form-item>
  35. </div>
  36. </div>
  37. <div class="row-item">
  38. <div class="hint-item"> </div>
  39. <div class="label-item">
  40. <div class="text-item">上传应用图标</div>
  41. <div class="required-item"></div>
  42. </div>
  43. <div class="input-item">
  44. <uploadFile
  45. :value.sync="urlListImage.url"
  46. :checkFile="fileWater"
  47. @overUpload="overUploadImage"
  48. @removeUpload="deleteImage"
  49. :fileCount="1"
  50. uploadType="image"
  51. :disabled="!accountId"
  52. />
  53. </div>
  54. </div>
  55. <div class="row-item">
  56. <div class="hint-item"> </div>
  57. <div class="label-item">
  58. <div class="text-item">上传应用文件</div>
  59. <div class="required-item"></div>
  60. </div>
  61. <div class="input-item">
  62. <a :href="attachmentUrl" style="margin-right:20px;display:block" v-if="attachmentUrl">{{attachmentName}}</a>
  63. <a-upload
  64. name="file"
  65. :multiple="false"
  66. :action="uploadAction"
  67. :headers="tokenHeader"
  68. :file-list="fileList"
  69. :showUploadList="false"
  70. :beforeUpload="beforeUpload"
  71. @change="handleChange"
  72. style="margin-right:20px"
  73. >
  74. <a-button :disabled="!accountId&&!urlListImage.url || loadDisabled">
  75. <a-icon type="upload" />
  76. {{loadDisabled?'上传中,请稍后':'文件上传'}}
  77. </a-button>
  78. </a-upload>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="moduler">
  83. <div class="opt">
  84. <a-button type="default" style="margin-right:15px" @click="goBack">返回列表</a-button>
  85. <!-- <a-button type="primary" @click="goNext" :loading="goNextloading">确定</a-button> -->
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import Vue from 'vue'
  92. import {ACCESS_TOKEN} from "@/store/mutation-types";
  93. import moment from 'moment'
  94. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  95. import Treeselect from '@/views/modules/Statistics/components/Treeselect.vue'
  96. import { TreeSelect } from 'ant-design-vue';
  97. import qs from 'qs'
  98. const SHOW_PARENT = TreeSelect.SHOW_PARENT;
  99. // import selectCheckAll from './toutiaoTime'
  100. import BMF from 'browser-md5-file'
  101. import uploadFile from '@/components/uploadFile.vue'
  102. var str = ""
  103. for (let i = 0; i < 7*48; i++) {
  104. str+='0'
  105. }
  106. const fileSuffix = [
  107. 'xlsx',
  108. 'xls',
  109. 'zip'
  110. ]
  111. export default {
  112. components: {
  113. Treeselect,
  114. uploadFile,
  115. },
  116. data() {
  117. return {
  118. platform:1,
  119. urlListImage: {
  120. url: '',
  121. md5:'',
  122. signature:'',
  123. imageToken:'',
  124. },
  125. attachmentName:'',
  126. attachmentUrl:'',
  127. treeData:[],
  128. accountId:undefined,
  129. goNextloading:false,
  130. goPlanShowloading:false,
  131. fileList:[],
  132. isEidt:false,
  133. loadDisabled:false,
  134. tokenHeader: {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)},
  135. uploadAction:'',
  136. imageinfo:{
  137. signature:'',
  138. imageToken:'',
  139. }
  140. }
  141. },
  142. watch: {
  143. accountId(n,o){
  144. this.urlListImage={
  145. url: '',
  146. signature:'',
  147. imageToken:'',
  148. }
  149. this.fileList=[];
  150. this. attachmentName='';
  151. this.attachmentUrl='';
  152. }
  153. },
  154. methods: {
  155. fileWater(file) {
  156. console.log(file)
  157. var bmf = new BMF()
  158. var that = this
  159. this.urlListImage = {
  160. url: '',
  161. md5: '',
  162. }
  163. return new Promise( (resolve, reject)=> {
  164. bmf.md5(file, (err, md5) => {
  165. that.urlListImage.name=file.name
  166. that.urlListImage.md5=md5
  167. that.urlListImage.size=file.size
  168. })
  169. resolve()
  170. })
  171. },
  172. deleteImage(urls) {
  173. console.log(urls, this.urlListImage.url)
  174. this.urlListImage.url='';
  175. },
  176. overUploadImage(urlAll) {
  177. console.log(urlAll)
  178. var that = this
  179. that.material = []
  180. that.imageArrList = []
  181. var img
  182. if (urlAll.length > 0) {
  183. urlAll.forEach((ele,index)=>{
  184. this.urlListImage.url=ele.url
  185. postAction('/ai/aiKuaiShouAppInfo/uploadAppIconImage',{
  186. accountId:this.accountId,
  187. url:'http:'+this.urlListImage.url
  188. }).then(res=>{
  189. this.urlListImage.signature=res.signature
  190. this.urlListImage.imageToken=res.imageToken
  191. })
  192. })
  193. } else {}
  194. },
  195. addImage(item) {
  196. this.addImageVisible = true
  197. this.addImageData = item
  198. },
  199. //获取表单的某一个属性值
  200. getFormData(className) {
  201. return this.form.getFieldValue(className)
  202. },
  203. goBack() {
  204. this.$router.replace('/autoLaunch/appIdList')
  205. this.$bus.$emit('remove', '/autoLaunch/newAppId')
  206. },
  207. //请求项目和账户内容
  208. accountHttp(){
  209. this.treeData=[];
  210. this.accountIds=[];
  211. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=2', {}).then(res => {
  212. if(res.success){
  213. // console.log(res);
  214. if(res.result){
  215. res.result.forEach((element,index) => {
  216. if(element){
  217. this.treeData.push({});
  218. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  219. this.treeData[index].value='project'+element.project.projectId;
  220. this.treeData[index].key=element.project.projectId;
  221. this.treeData[index].mediaId=element.project.mediaId;
  222. this.treeData[index].children=[];
  223. if(element.account.length){
  224. element.account.forEach((ele,i)=>{
  225. this.treeData[index].children.push({});
  226. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_'+element.project.projectName;
  227. this.treeData[index].children[i].value=ele.accountId;
  228. this.treeData[index].children[i].key=ele.accountId;
  229. })
  230. }
  231. }
  232. });
  233. // console.log(this.treeData)
  234. }
  235. }
  236. })
  237. },
  238. beforeUpload(file) {
  239. // ${this.form.project}
  240. if (process.env.NODE_ENV == 'development') {
  241. this.uploadAction= `/jeecg-boot/ai/aiKuaiShouAppInfo/importAppExcel?accountId=${this.accountId}&platform=${this.platform}&imageToken=${this.urlListImage.imageToken}`
  242. }
  243. else if (process.env.NODE_ENV == 'debug') {
  244. }
  245. else if (process.env.NODE_ENV == 'production') {
  246. this.uploadAction= `${this.axios.defaults.baseURL}/ai/aiKuaiShouAppInfo/importAppExcel?accountId=${this.accountId}&platform=${this.platform}&imageToken=${this.urlListImage.imageToken}`
  247. }
  248. this.loadDisabled = true
  249. const size = (Number(file.size) / (1024 * 1024)).toFixed(2)
  250. const fileName = file.name
  251. const fileStrArr = fileName.split('.')
  252. const suffix = fileStrArr[fileStrArr.length - 1]
  253. let result = fileSuffix.some((item) => {
  254. return item === suffix
  255. })
  256. if (!result) {
  257. this.$message.error('不支持该文件类型')
  258. this.loadDisabled = false
  259. return false
  260. }
  261. // if (size > 10) {
  262. // this.$message.error('文件不能大于10MB')
  263. // this.loadDisabled = false
  264. // return false
  265. // }
  266. },
  267. handleChange(info) {
  268. console.log(info)
  269. let fileList = [...info.fileList];
  270. // 1. Limit the number of uploaded files
  271. // Only to show two recent uploaded files, and old ones will be replaced by the new
  272. fileList = fileList.slice(-2);
  273. // 2. read from response and show file link
  274. fileList = fileList.map(file => {
  275. if (file.response) {
  276. // Component will show file.url as link
  277. file.url = file.response.url;
  278. }
  279. return file;
  280. });
  281. if(fileList.length>0){
  282. this.fileList = [
  283. {
  284. ...fileList[fileList.length-1]
  285. }
  286. ]
  287. }else{
  288. this.fileList=[]
  289. }
  290. // this.loadDisabled = false
  291. // this.$message.success('文件导入成功,异步创建中,请稍后查看...')
  292. if (info.file.status !== 'uploading') {
  293. console.log(info.file, info.fileList)
  294. }
  295. if (info.file.status === 'done') {
  296. this.loadDisabled = false
  297. if(info.file.response.code==0){
  298. this.$message.success(info.file.response.message)
  299. this.$router.replace('/autoLaunch/appIdList')
  300. this.$bus.$emit('remove', '/autoLaunch/newAppId')
  301. }else{
  302. this.$message.error(info.file.response.message)
  303. }
  304. } else if (info.file.status === 'error') {
  305. this.$message.error(`${info.file.name}上传失败`)
  306. this.loadDisabled = false
  307. }
  308. // console.log(this.form)
  309. },
  310. },
  311. mounted() {
  312. this.accountHttp()
  313. },
  314. }
  315. </script>
  316. <style lang="scss">
  317. .newAppId{
  318. .ant-btn-danger {
  319. background-color: #ff4d4f !important;
  320. }
  321. }
  322. .ant-tooltip-inner,
  323. .ant-tooltip-arrow::before {
  324. background-color: #fff;
  325. color: #333;
  326. }
  327. .ant-tooltip-inner {
  328. span {
  329. display: block;
  330. }
  331. }
  332. .ant-tooltip {
  333. max-width: 450px;
  334. }
  335. .newPlan {
  336. .ant-radio-button-wrapper {
  337. min-width: 80px;
  338. text-align: center;
  339. }
  340. .ant-form-item {
  341. -webkit-box-sizing: border-box;
  342. box-sizing: border-box;
  343. margin: 0;
  344. padding: 0;
  345. color: rgba(0, 0, 0, 0.65);
  346. font-size: 14px;
  347. font-variant: tabular-nums;
  348. line-height: 1.5;
  349. list-style: none;
  350. -webkit-font-feature-settings: 'tnum';
  351. font-feature-settings: 'tnum';
  352. vertical-align: top;
  353. }
  354. .directedBody {
  355. .ant-form-item {
  356. margin-bottom: 20px;
  357. }
  358. }
  359. }
  360. </style>
  361. <style lang="scss" scoped>
  362. .newAppId {
  363. font-family: PingFangSC-Regular, tahoma, arial, 'Hiragino Sans GB', 'Microsoft yahei', sans-serif;
  364. color: #333;
  365. ul,
  366. li {
  367. margin: 0;
  368. padding: 0;
  369. }
  370. .moduler {
  371. background: #fff;
  372. margin-bottom: 16px;
  373. position: relative;
  374. padding: 32px 24px 48px 32px;
  375. border-radius: 4px;
  376. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
  377. .moduler-title {
  378. display: flex;
  379. align-items: center;
  380. font-size: 22px;
  381. margin-bottom: 20px;
  382. }
  383. .row-item {
  384. display: flex;
  385. justify-content: flex-start;
  386. align-items: center;
  387. margin-bottom: 32px;
  388. }
  389. .row-item:last-of-type {
  390. margin-bottom: 0;
  391. }
  392. .row-item .hint-item {
  393. width: 24px;
  394. min-width: 24px;
  395. align-self: flex-start;
  396. line-height: 20px;
  397. height: 20px;
  398. margin-top: 9px;
  399. }
  400. .row-item .label-item {
  401. position: relative;
  402. align-items: flex-start;
  403. align-self: flex-start;
  404. line-height: 20px;
  405. height: 20px;
  406. margin-top: 10px;
  407. width: 80px;
  408. min-width: 80px;
  409. .text-item {
  410. font-size: 14px;
  411. width: 60px;
  412. }
  413. }
  414. .row-item .required-item {
  415. width: 4px;
  416. height: 4px;
  417. border-radius: 2px;
  418. background: #f45858;
  419. position: absolute;
  420. right: 10px;
  421. top: 50%;
  422. transform: translateY(-50%);
  423. }
  424. .row-item .input-item {
  425. min-width: 480px;
  426. position: relative;
  427. // height: 35px;
  428. .tip {
  429. font-size: 12px;
  430. color: tomato;
  431. }
  432. }
  433. }
  434. .opt {
  435. text-align: right;
  436. }
  437. }
  438. </style>