detailsPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList">返回列表
  7. </el-button>
  8. <div class="upper_right_button">
  9. <el-button class="el-button--small-yh"
  10. type="primary"
  11. size="small"
  12. :loading="buttonLoading"
  13. @click.stop="saveData"
  14. >保存数据
  15. </el-button>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="customer-main">
  20. <containerTitle title="基础信息"></containerTitle>
  21. <basic-container>
  22. <avue-form class="trading-form" ref="form" v-model="form" :option="option">
  23. <template slot="remark">
  24. <el-input type="textarea"
  25. v-model="form.remark"
  26. size="small"
  27. rows="2"
  28. autocomplete="off"
  29. placeholder="">
  30. </el-input>
  31. </template>
  32. </avue-form>
  33. </basic-container>
  34. <containerTitle title="明细列表"></containerTitle>
  35. <basic-container>
  36. <avue-crud :option="itemsOption"
  37. :data="dataList"
  38. ref="crud"
  39. v-model="itemsForm"
  40. @search-reset="searchReset"
  41. @row-update="rowUpdate"
  42. @selection-change="selectionChange"
  43. @current-change="currentChange"
  44. @size-change="sizeChange"
  45. @refresh-change="refreshChange">
  46. <template slot="downloadUrl" slot-scope="{ row }">
  47. <el-input
  48. v-if="row.$cellEdit"
  49. v-model="row.downloadUrl"
  50. style="width: 80%"
  51. size="small"
  52. >
  53. </el-input>
  54. <el-button
  55. style="width: 20%"
  56. size="small"
  57. v-if="row.$cellEdit"
  58. @click="uploadFiles(row)"
  59. >
  60. 附件
  61. </el-button>
  62. <span v-else>{{ row.downloadUrl }}</span>
  63. </template>
  64. <template slot="versionDesc" slot-scope="{ row }">
  65. <el-input type="textarea"
  66. v-if="row.$cellEdit"
  67. v-model="row.versionDesc"
  68. size="small"
  69. autosize
  70. placeholder="">
  71. </el-input>
  72. <span v-else>{{ row.versionDesc }}</span>
  73. </template>
  74. <template slot="isRelease" slot-scope="{ row, index }">
  75. <el-select
  76. v-if="row.$cellEdit"
  77. v-model="row.isRelease"
  78. size="small"
  79. @change="isReleaseChange(row,index)"
  80. >
  81. <el-option
  82. v-for="(item,index) in isReleaseList"
  83. :key="index"
  84. :label="item.label"
  85. :value="item.value"
  86. >
  87. </el-option>
  88. </el-select>
  89. <span v-else>{{ row.isRelease ===1?"是":"否" }}</span>
  90. </template>
  91. <template slot="menuLeft">
  92. <el-button type="primary"
  93. size="small"
  94. :loading="buttonLoading"
  95. @click="addDetail"
  96. >录入明细
  97. </el-button>
  98. </template>
  99. <template slot-scope="scope" slot="menu">
  100. <el-button
  101. type="text"
  102. size="small"
  103. icon="el-icon-edit"
  104. @click.stop="rowCell(scope.row,scope.index)"
  105. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  106. </el-button>
  107. <el-button
  108. type="text"
  109. size="small"
  110. icon="el-icon-delete"
  111. @click.stop="rowDel(scope.row,scope.index)"
  112. >删除
  113. </el-button>
  114. </template>
  115. </avue-crud>
  116. </basic-container>
  117. <el-dialog
  118. title="上传附件"
  119. append-to-body
  120. :visible.sync="excelBox"
  121. width="555px"
  122. v-dialog-drag
  123. >
  124. <avue-form
  125. :option="excelOption"
  126. v-model="excelForm"
  127. table-loading="excelLoading"
  128. :upload-before="uploadBefore"
  129. :upload-after="uploadAfter"
  130. >
  131. </avue-form>
  132. </el-dialog>
  133. </div>
  134. </div>
  135. </template>
  136. <script>
  137. import option from "./config/detailsPage.json";
  138. import { contrastObj,contrastList } from "@/util/contrastData";
  139. import {appSave ,appDetail,appDetailRemove} from "@/api/application/application";
  140. export default {
  141. name: "receiptDetailsPage",
  142. props: {
  143. detailData: {
  144. type: Object
  145. }
  146. },
  147. components:{
  148. },
  149. data() {
  150. return {
  151. buttonLoading:false,
  152. form: {},
  153. itemsForm:{},
  154. dataList: [],
  155. itemsOption: option,
  156. option: {
  157. menuBtn: false,
  158. labelWidth: 100,
  159. column: [
  160. {
  161. label: 'app名称',
  162. prop: 'appName',
  163. span: 8,
  164. rules: [
  165. {
  166. required: true,
  167. message: ' ',
  168. trigger: 'blur'
  169. }
  170. ]
  171. },{
  172. label: '应用描述',
  173. prop: 'appDesc',
  174. span: 8,
  175. },
  176. {
  177. label: '类型',
  178. prop: 'type',
  179. type:'select',
  180. dicData:[{
  181. label:'安卓',
  182. value:0,
  183. },
  184. {
  185. label:'苹果',
  186. value:1,
  187. }],
  188. span: 8,
  189. },
  190. {
  191. label: '苹果appStoreId',
  192. prop: 'appStoreId',
  193. span: 8,
  194. },
  195. {
  196. label: '苹果bundleId',
  197. prop: 'bundleId',
  198. span: 8,
  199. },
  200. {
  201. label: '安卓包名',
  202. prop: 'packageName',
  203. span: 8,
  204. rules: [
  205. {
  206. required: true,
  207. message: ' ',
  208. trigger: 'blur'
  209. }
  210. ]
  211. },
  212. ],
  213. },
  214. selectRow:{},
  215. isReleaseList:[
  216. {
  217. label: "是",
  218. value: 1
  219. },
  220. {
  221. label: "否",
  222. value: 0
  223. }
  224. ],
  225. excelBox: false,
  226. excelLoading: false,
  227. excelForm: {},
  228. excelOption: {
  229. submitBtn: false,
  230. emptyBtn: false,
  231. column: [
  232. {
  233. label: "附件上传",
  234. prop: "excelFile",
  235. type: "upload",
  236. drag: true,
  237. dataType: "string",
  238. loadText: "模板上传中,请稍等",
  239. span: 24,
  240. propsHttp: {
  241. res: "data",
  242. url: "link"
  243. },
  244. action: "/api/blade-resource/oss/endpoint/put-file"
  245. }
  246. ]
  247. },
  248. oldForm:{},
  249. oldDataList:[],
  250. }
  251. },
  252. created() {
  253. if(this.detailData.id){
  254. this.buttonLoading = true
  255. appDetail(this.detailData.id).then(res=>{
  256. this.afterEcho(res.data.data)
  257. }).finally(()=>{
  258. this.buttonLoading = false
  259. })
  260. }
  261. },
  262. watch:{
  263. 'excelForm.excelFile'(val) {
  264. this.selectRow.downloadUrl = val
  265. },
  266. },
  267. mounted() {
  268. },
  269. methods: {
  270. isReleaseChange(row,indexs){
  271. if(row.isRelease === 1){
  272. //如果其他版本有发布的
  273. let yes ;
  274. this.dataList.map((item,index)=>{
  275. if(indexs != index && item.isRelease === 1){
  276. yes = true
  277. }
  278. })
  279. if(yes){
  280. this.$message.warning("已有其他版本发布!")
  281. row.isRelease = 0
  282. }
  283. }
  284. },
  285. uploadFiles(row){
  286. this.selectRow = row
  287. this.excelBox = true
  288. },
  289. uploadBefore(file, done, loading) {
  290. done();
  291. loading = true;
  292. },
  293. uploadAfter(res, done, loading, column) {
  294. this.excelBox = false;
  295. this.$message.success("上传成功!");
  296. loading = false;
  297. done();
  298. },
  299. rowUpdate(row, index, done) {
  300. done(row);
  301. },
  302. rowCell(row,index){
  303. this.$refs.crud.rowCell(row, index)
  304. },
  305. rowDel(row,index){
  306. this.$confirm("确定将选择数据删除?", {
  307. confirmButtonText: "确定",
  308. cancelButtonText: "取消",
  309. type: "warning"
  310. }).then(() => {
  311. if(row.id){
  312. appDetailRemove(row.id).then(res=>{
  313. if(res.data.success){
  314. this.$message.success("操作成功!")
  315. this.dataList.splice(index, 1);
  316. }
  317. })
  318. }else{
  319. this.dataList.splice(index, 1);
  320. }
  321. })
  322. },
  323. addDetail(){
  324. this.$refs.crud.rowCellAdd();
  325. },
  326. searchReset() {
  327. console.log('1')
  328. },
  329. selectionChange() {
  330. console.log('1')
  331. },
  332. currentChange() {
  333. console.log('1')
  334. },
  335. sizeChange() {
  336. console.log('1')
  337. },
  338. refreshChange() {
  339. console.log('1')
  340. },
  341. saveData(type){
  342. this.buttonLoading = true
  343. let params = {
  344. ...this.form,
  345. appVersionList: this.dataList
  346. }
  347. appSave(params).then(res =>{
  348. if(res.data.success){
  349. this.$message.success("操作成功!")
  350. this.afterEcho(res.data.data)
  351. }
  352. }).finally(()=>{
  353. this.buttonLoading = false
  354. if(type === true){
  355. this.$emit("goBack");
  356. }
  357. })
  358. },
  359. afterEcho(data){
  360. this.form = data
  361. this.oldForm = Object.assign({},data);
  362. if(data.appVersionList){
  363. this.dataList = data.appVersionList
  364. this.oldDataList = this.deepClone(data.appVersionList)
  365. }
  366. },
  367. verificationData(){
  368. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  369. ){
  370. this.$confirm("数据发生变化,请先提交保存!", "提示", {
  371. confirmButtonText: "保存",
  372. cancelButtonText: "取消",
  373. type: "warning",
  374. }).then(() => {
  375. this.saveData()
  376. }).catch(()=>{
  377. return false
  378. })
  379. }else{
  380. return true
  381. }
  382. },
  383. backToList(){
  384. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  385. ){
  386. this.$confirm("是否保存当前页面?", "提示", {
  387. confirmButtonText: "保存",
  388. cancelButtonText: "取消",
  389. type: "warning",
  390. }).then(() => {
  391. this.saveData(true)
  392. }).catch(()=>{
  393. this.$emit("goBack");
  394. })
  395. }else{
  396. this.$emit("goBack");
  397. }
  398. },
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. ::v-deep .el-form-item {
  404. margin-bottom: 0;
  405. }
  406. .trading-form ::v-deep .el-form-item {
  407. margin-bottom: 8px !important;
  408. }
  409. .required_fields{
  410. color: #F56C6C;
  411. display:inline-block;
  412. width: 7%
  413. }
  414. .upper_right_button{
  415. display: flex;
  416. position: fixed;
  417. right: 12px;
  418. top: 47px;
  419. }
  420. </style>