DialogSettingStoreStatus.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div>
  3. <el-dialog title="设置" v-model="dialogVisible">
  4. <div>
  5. <el-form label-width="auto">
  6. <el-form-item label="可用状态">
  7. <el-radio-group
  8. v-model="state.form.status"
  9. class="ml-4"
  10. name="status"
  11. >
  12. <el-radio :label="0" size="large">可用</el-radio>
  13. <el-radio :label="1" size="large">禁用</el-radio>
  14. </el-radio-group>
  15. </el-form-item>
  16. <el-form-item label="交易方式">
  17. <el-radio-group v-model="state.form.tradeType" class="ml-4">
  18. <el-radio :label="0" size="large">线下交易</el-radio>
  19. <el-radio :label="1" size="large">线上交易</el-radio>
  20. <el-radio :label="2" size="large">根据商品情况自行设定</el-radio>
  21. </el-radio-group>
  22. </el-form-item>
  23. <el-form-item label="商品审核">
  24. <el-radio-group v-model="state.form.needVerify" class="ml-4">
  25. <el-radio :label="0" size="large">无需审核</el-radio>
  26. <el-radio :label="1" size="large">需要审核后才能上架</el-radio>
  27. </el-radio-group>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <template #footer>
  32. <div>
  33. <el-button @click="dialogVisible = false">取 消</el-button>
  34. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  35. </div>
  36. </template>
  37. </el-dialog>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import { request } from "@/utils";
  42. import { ElMessage } from "element-plus";
  43. import { ref, computed, defineProps, defineEmits, watch, reactive } from "vue";
  44. const props = defineProps({
  45. show: {
  46. type: Boolean,
  47. default: false
  48. },
  49. id: {
  50. type: Number
  51. }
  52. });
  53. const emits = defineEmits(["update:show", "success"]);
  54. const dialogVisible = computed({
  55. get() {
  56. return props.show;
  57. },
  58. set(n) {
  59. emits("update:show", n);
  60. }
  61. });
  62. watch(
  63. () => dialogVisible.value,
  64. n => {
  65. if (n) {
  66. getDetail();
  67. } else {
  68. }
  69. }
  70. );
  71. const status = ref(0);
  72. const radio1 = ref(3);
  73. const state = reactive({
  74. detail: {},
  75. form: {
  76. status: 0,
  77. tradeType: 0,
  78. needVerify: 0
  79. }
  80. });
  81. const getDetail = () => {
  82. if (!props.id) {
  83. return;
  84. }
  85. request
  86. .get(`/articleService/serviceProvider/shop?id=${props.id}`)
  87. .then(resp => {
  88. state.detail = resp.data;
  89. state.form.status = resp.data.status;
  90. state.form.tradeType = resp.data.tradeType;
  91. state.form.needVerify = resp.data.needVerify;
  92. });
  93. };
  94. const handleSubmit = () => {
  95. request
  96. .post("/articleService/serviceProvider/shop/setting", {
  97. id: props.id,
  98. ...state.form
  99. })
  100. .then(resp => {
  101. ElMessage.success(resp.message);
  102. dialogVisible.value = false;
  103. emits("success");
  104. });
  105. };
  106. </script>