newAppId.vue 15 KB

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