ItemModal.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="modal"
  5. width="500px"
  6. :close-on-click-modal="false"
  7. @close="
  8. res => {
  9. $emit('cancel');
  10. }
  11. "
  12. >
  13. <el-form ref="form" :model="form" :rules="rules" label-width="160px">
  14. <el-form-item label="列表预览图图片">
  15. <img
  16. :src="form.listPreview"
  17. class="pre-img"
  18. @click="
  19. () =>
  20. this.$AdvanceViewImageModal({
  21. items: [{ src: form.listPreview }]
  22. })
  23. "
  24. />
  25. </el-form-item>
  26. <el-form-item label="详情页面预览图图片">
  27. <img
  28. :src="form.detailPreview"
  29. class="pre-img"
  30. @click="
  31. () =>
  32. this.$AdvanceViewImageModal({
  33. items: [{ src: form.detailPreview }]
  34. })
  35. "
  36. />
  37. </el-form-item>
  38. <el-form-item label="高清图">
  39. <img
  40. :src="form.hdLogoPhoto"
  41. class="pre-img"
  42. @click="
  43. () =>
  44. this.$AdvanceViewImageModal({
  45. items: [{ src: form.hdLogoPhoto }]
  46. })
  47. "
  48. />
  49. </el-form-item>
  50. <el-form-item label="原图">
  51. <img
  52. :src="form.originPhoto"
  53. class="pre-img"
  54. @click="
  55. () =>
  56. this.$AdvanceViewImageModal({
  57. items: [{ src: form.originPhoto }]
  58. })
  59. "
  60. />
  61. </el-form-item>
  62. <el-form-item label="是否精选">
  63. <el-radio-group v-model="form.isBeautiful" prop="isShow">
  64. <el-radio :label="true">是</el-radio>
  65. <el-radio :label="false">否</el-radio>
  66. </el-radio-group>
  67. </el-form-item>
  68. <el-form-item label="状态">
  69. <el-radio-group v-model="form.isShow" prop="isShow">
  70. <el-radio :label="true">上架</el-radio>
  71. <el-radio :label="false">下架</el-radio>
  72. </el-radio-group>
  73. </el-form-item>
  74. </el-form>
  75. <span slot="footer" class="dialog-footer">
  76. <el-button @click="modal = false">取消</el-button>
  77. <el-button type="primary" @click="handleConfirm">确定</el-button>
  78. </span>
  79. </el-dialog>
  80. </template>
  81. <script>
  82. import { getItem, updateItem } from '@/api/photoWarehouse';
  83. export default {
  84. name: 'ImageGoodsItemModal',
  85. props: {
  86. id: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data() {
  92. return {
  93. modal: true,
  94. form: {
  95. isShow: false,
  96. isBeautiful: false,
  97. hdLogoPhotoOriginPrice: 0,
  98. hdLogoPhotoPrice: 0,
  99. originPhotoOriginPrice: 0
  100. originPhotoPrice: 0
  101. },
  102. rules: {
  103. originPhotoOriginPrice: [
  104. { required: true, message: '请输入正确的价格', trigger: 'blur' }
  105. ],
  106. originPhotoPrice: [
  107. { required: true, message: '请输入正确的价格', trigger: 'blur' }
  108. ],
  109. hdLogoPhotoOriginPrice: [
  110. { required: true, message: '请输入正确的价格', trigger: 'blur' }
  111. ],
  112. hdLogoPhotoPrice: [
  113. { required: true, message: '请输入正确的价格', trigger: 'blur' }
  114. ]
  115. },
  116. typeOptions: []
  117. };
  118. },
  119. computed: {
  120. title() {
  121. if (this.id) {
  122. return '编辑照片';
  123. } else {
  124. return '新增照片';
  125. }
  126. }
  127. },
  128. watch: {
  129. id: {
  130. handler(id) {
  131. id && this.loadData();
  132. },
  133. immediate: true
  134. }
  135. },
  136. mounted() {},
  137. methods: {
  138. async loadData() {
  139. const { success, data, msg } = await getItem({
  140. id: this.id
  141. });
  142. if (success) {
  143. let result = data;
  144. result.imgUrl = [
  145. {
  146. url: data.imgUrl
  147. }
  148. ];
  149. this.form = result;
  150. }
  151. },
  152. handleConfirm() {
  153. this.$refs.form.validate(async valid => {
  154. if (valid) {
  155. let params = Object.assign({}, this.form);
  156. if (this.id) params.id = this.id;
  157. const { success, msg } = await updateItem(params);
  158. if (success) {
  159. this.$success('保存成功!');
  160. this.modal = false;
  161. this.$g_emit('photo_reload');
  162. }
  163. }
  164. });
  165. }
  166. }
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. .pre-img {
  171. height: 80px;
  172. }
  173. </style>