detailsPage.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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="menuLeft">
  47. <el-button type="primary"
  48. size="small"
  49. :loading="buttonLoading"
  50. @click="addDetail"
  51. >录入明细
  52. </el-button>
  53. </template>
  54. <template slot-scope="scope" slot="menu">
  55. <el-button
  56. type="text"
  57. size="small"
  58. icon="el-icon-edit"
  59. @click.stop="rowCell(scope.row,scope.index)"
  60. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  61. </el-button>
  62. <el-button
  63. type="text"
  64. size="small"
  65. icon="el-icon-delete"
  66. @click.stop="rowDel(scope.row,scope.index)"
  67. >删除
  68. </el-button>
  69. </template>
  70. </avue-crud>
  71. </basic-container>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import option from "./config/detailsPage.json";
  77. import { contrastObj,contrastList } from "@/util/contrastData";
  78. import {appSave ,appDetail,appDetailRemove} from "@/api/application/application";
  79. export default {
  80. name: "receiptDetailsPage",
  81. props: {
  82. detailData: {
  83. type: Object
  84. }
  85. },
  86. components:{
  87. },
  88. data() {
  89. return {
  90. buttonLoading:false,
  91. form: {},
  92. itemsForm:{},
  93. dataList: [],
  94. itemsOption: option,
  95. option: {
  96. menuBtn: false,
  97. labelWidth: 100,
  98. column: [
  99. {
  100. label: 'app名称',
  101. prop: 'appName',
  102. span: 8,
  103. rules: [
  104. {
  105. required: true,
  106. message: ' ',
  107. trigger: 'blur'
  108. }
  109. ]
  110. },{
  111. label: '应用描述',
  112. prop: 'appDesc',
  113. span: 8,
  114. },
  115. {
  116. label: '类型',
  117. prop: 'type',
  118. type:'select',
  119. dicData:[{
  120. label:'安卓',
  121. value:0,
  122. },
  123. {
  124. label:'苹果',
  125. value:1,
  126. }],
  127. span: 8,
  128. },
  129. {
  130. label: '苹果appStoreId',
  131. prop: 'appStoreId',
  132. span: 8,
  133. },
  134. {
  135. label: '苹果bundleId',
  136. prop: 'bundleId',
  137. span: 8,
  138. },
  139. {
  140. label: '安卓包名',
  141. prop: 'packageName',
  142. span: 8,
  143. },
  144. ],
  145. },
  146. oldForm:{},
  147. oldDataList:[],
  148. }
  149. },
  150. created() {
  151. if(this.detailData.id){
  152. this.buttonLoading = true
  153. appDetail(this.detailData.id).then(res=>{
  154. this.afterEcho(res.data.data)
  155. }).finally(()=>{
  156. this.buttonLoading = false
  157. })
  158. }
  159. },
  160. mounted() {
  161. },
  162. methods: {
  163. rowUpdate(row, index, done) {
  164. done(row);
  165. },
  166. rowCell(row,index){
  167. this.$refs.crud.rowCell(row, index)
  168. },
  169. rowDel(row,index){
  170. this.$confirm("确定将选择数据删除?", {
  171. confirmButtonText: "确定",
  172. cancelButtonText: "取消",
  173. type: "warning"
  174. }).then(() => {
  175. if(row.id){
  176. appDetailRemove(row.id).then(res=>{
  177. if(res.data.success){
  178. this.$message.success("操作成功!")
  179. this.dataList.splice(index, 1);
  180. }
  181. })
  182. }else{
  183. this.dataList.splice(index, 1);
  184. }
  185. })
  186. },
  187. addDetail(){
  188. this.$refs.crud.rowCellAdd();
  189. },
  190. searchReset() {
  191. console.log('1')
  192. },
  193. selectionChange() {
  194. console.log('1')
  195. },
  196. currentChange() {
  197. console.log('1')
  198. },
  199. sizeChange() {
  200. console.log('1')
  201. },
  202. refreshChange() {
  203. console.log('1')
  204. },
  205. saveData(type){
  206. this.buttonLoading = true
  207. let params = {
  208. ...this.form,
  209. appVersionList: this.dataList
  210. }
  211. appSave(params).then(res =>{
  212. if(res.data.success){
  213. this.$message.success("操作成功!")
  214. this.afterEcho(res.data.data)
  215. }
  216. }).finally(()=>{
  217. this.buttonLoading = false
  218. if(type === true){
  219. this.$emit("goBack");
  220. }
  221. })
  222. },
  223. afterEcho(data){
  224. this.form = data
  225. this.oldForm = Object.assign({},data);
  226. if(data.appVersionList){
  227. this.dataList = data.appVersionList
  228. this.oldDataList = this.deepClone(data.appVersionList)
  229. }
  230. },
  231. verificationData(){
  232. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  233. ){
  234. this.$confirm("数据发生变化,请先提交保存!", "提示", {
  235. confirmButtonText: "保存",
  236. cancelButtonText: "取消",
  237. type: "warning",
  238. }).then(() => {
  239. this.saveData()
  240. }).catch(()=>{
  241. return false
  242. })
  243. }else{
  244. return true
  245. }
  246. },
  247. backToList(){
  248. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  249. ){
  250. this.$confirm("是否保存当前页面?", "提示", {
  251. confirmButtonText: "保存",
  252. cancelButtonText: "取消",
  253. type: "warning",
  254. }).then(() => {
  255. this.saveData(true)
  256. }).catch(()=>{
  257. this.$emit("goBack");
  258. })
  259. }else{
  260. this.$emit("goBack");
  261. }
  262. },
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. ::v-deep .el-form-item {
  268. margin-bottom: 0;
  269. }
  270. .trading-form ::v-deep .el-form-item {
  271. margin-bottom: 8px !important;
  272. }
  273. .required_fields{
  274. color: #F56C6C;
  275. display:inline-block;
  276. width: 7%
  277. }
  278. .upper_right_button{
  279. display: flex;
  280. position: fixed;
  281. right: 12px;
  282. top: 47px;
  283. }
  284. </style>