AppDeployControlKey.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div class="app-deploy-control-key">
  3. <el-input
  4. v-if="keyType === 'string'"
  5. v-model.trim="data"
  6. style="width: 100%"
  7. placeholder="请输入内容"
  8. clearable
  9. @change="dataChange"
  10. ></el-input>
  11. <el-input
  12. v-if="keyType === 'number'"
  13. v-model.number="data"
  14. type="number"
  15. style="width: 140px"
  16. :controls="false"
  17. placeholder="请输入数字"
  18. @change="dataChange"
  19. ></el-input>
  20. <el-radio-group
  21. v-if="keyType === 'boolean'"
  22. v-model="data"
  23. @change="dataChange"
  24. >
  25. <el-radio :label="null">无</el-radio>
  26. <el-radio :label="true">是</el-radio>
  27. <el-radio :label="false">否</el-radio>
  28. </el-radio-group>
  29. <el-date-picker
  30. v-if="keyType === 'time'"
  31. v-model="data"
  32. type="datetime"
  33. style="width: 100%"
  34. value-format="timestamp"
  35. placeholder="选择日期时间"
  36. clearable
  37. @change="dataChange"
  38. >
  39. </el-date-picker>
  40. </div>
  41. </template>
  42. <script>
  43. export default {
  44. name: "app-deploy-control-key",
  45. props: {
  46. value: { type: [Number, String, Boolean] },
  47. keyType: {
  48. type: String,
  49. default: "number",
  50. validator: (val) => ["number", "time", "string", "boolean"].includes(val),
  51. },
  52. },
  53. watch: {
  54. value: {
  55. immediate: true,
  56. handler(val) {
  57. this.data = val;
  58. },
  59. },
  60. },
  61. data() {
  62. return {
  63. data: null,
  64. };
  65. },
  66. methods: {
  67. dataChange() {
  68. // console.log(this.data);
  69. this.$emit("input", this.data);
  70. this.$emit("change", this.data);
  71. },
  72. },
  73. };
  74. </script>