InstantAppUpdate.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <base-dialog :width="900" @cancel="cancelDialog">
  3. <div slot="header">{{ $t('common.update') }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('aice.mounted_apps')" :count="params.data.length" :action="action" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form :form="form.fc" v-bind="formItemLayout" hideRequiredMark>
  8. <a-form-item :label="$t('aice.mounted_apps.mounts')">
  9. <a-textarea v-decorator="decorators.mounts" :placeholder="mountsExample" :auto-size="{ minRows: 3, maxRows: 5 }" />
  10. </a-form-item>
  11. <a-form-item :label="$t('aice.template')">
  12. <base-select
  13. v-decorator="decorators.image_id"
  14. resource="images"
  15. :params="templateParams"
  16. filterable
  17. :selectProps="{ placeholder: $t('common.tips.select', [$t('aice.template')]) }" />
  18. </a-form-item>
  19. </a-form>
  20. </div>
  21. <div slot="footer">
  22. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  23. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  24. </div>
  25. </base-dialog>
  26. </template>
  27. <script>
  28. import { mapGetters } from 'vuex'
  29. import DialogMixin from '@/mixins/dialog'
  30. import WindowsMixin from '@/mixins/windows'
  31. export default {
  32. name: 'PhoneImageUpdateDialog',
  33. mixins: [DialogMixin, WindowsMixin],
  34. data () {
  35. return {
  36. loading: false,
  37. form: {
  38. fc: this.$form.createForm(this, {
  39. onValuesChange: (props, values) => {
  40. Object.keys(values).forEach((key) => {
  41. this.$set(this.form.fd, key, values[key])
  42. })
  43. },
  44. }),
  45. fd: {},
  46. },
  47. decorators: {
  48. mounts: [
  49. 'mounts',
  50. {
  51. initialValue: this.params.data[0].mounts.join('\n'),
  52. rules: [
  53. { required: true, message: this.$t('common.tips.input', [this.$t('aice.mounted_apps.mounts')]) },
  54. ],
  55. },
  56. ],
  57. image_id: [
  58. 'image_id',
  59. {
  60. initialValue: this.params.data[0].image_id,
  61. rules: [
  62. { required: true, message: this.$t('common.tips.input', [this.$t('aice.template')]) },
  63. ],
  64. },
  65. ],
  66. },
  67. formItemLayout: {
  68. wrapperCol: {
  69. span: 20,
  70. },
  71. labelCol: {
  72. span: 3,
  73. },
  74. },
  75. }
  76. },
  77. computed: {
  78. ...mapGetters(['userInfo']),
  79. columns () {
  80. const showFields = ['name', 'package', 'version', 'image']
  81. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  82. },
  83. mountsExample () {
  84. return '/data/app/~~AiggKR4DW03_Ue4jSG2YmQ==\n/data/data/com.ss.android.ugc.aweme\n/data/media/0/Android/data/com.ss.android.ugc.aweme'
  85. },
  86. templateParams () {
  87. const ret = {
  88. scope: this.scope,
  89. 'disk_formats.0': 'tgz',
  90. details: false,
  91. }
  92. return ret
  93. },
  94. },
  95. methods: {
  96. async handleConfirm () {
  97. try {
  98. const values = await this.form.fc.validateFields()
  99. const manager = new this.$Manager('instant_apps', '')
  100. const mountPaths = values.mounts.split('\n')
  101. const data = {
  102. mounts: mountPaths,
  103. image_id: values.image_id,
  104. }
  105. manager.update({
  106. id: this.params.data[0].id,
  107. data: data,
  108. })
  109. } catch (error) {
  110. throw error
  111. } finally {
  112. this.loading = false
  113. }
  114. this.params.callback && this.params.callback()
  115. this.cancelDialog()
  116. this.params.refresh && this.params.refresh()
  117. },
  118. },
  119. }
  120. </script>