GroupModelAdd.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div>
  3. <el-dialog v-model="dialogVisible" title="装置端子关系配置" width="30%" @close="handleClose"
  4. :close-on-click-modal="false">
  5. <span>装置编码:</span>
  6. <el-input v-model="iedValue" :maxlength="5" :show-word-limit="true" style="width: 300px;"
  7. placeholder="请输入装置编码"></el-input>
  8. <template #footer>
  9. <span class="dialog-footer">
  10. <el-button @click="cancels">取消</el-button>
  11. <el-button type="primary" @click="sureClick">确定</el-button>
  12. </span>
  13. </template>
  14. </el-dialog>
  15. </div>
  16. </template>
  17. <script>
  18. import { ref, onMounted, watch, onBeforeUnmount } from 'vue';
  19. import flow from '@/api/flow/flow';
  20. import { ElMessage, ElLoading } from 'element-plus';
  21. export default {
  22. props: {
  23. groupType: {
  24. type: Boolean,
  25. required: true,
  26. },//模态框显示
  27. modelId: {
  28. type: String,
  29. required: true,
  30. },//DrawDesigns.vue传过来的模型id
  31. },
  32. setup(props, { emit }) {
  33. let dialogVisible = ref(false)//模态框打开/关闭状态
  34. let iedValue = ref('')//输入框value值
  35. let modelType = ref("")//本组件的模型id
  36. // 初始化组件
  37. function reload() {
  38. dialogVisible.value = props.groupType
  39. modelType.value = props.modelId
  40. }
  41. // 关闭模态框
  42. function modalClose() {
  43. dialogVisible.value = false
  44. emit("groupBack", dialogVisible.value)
  45. }
  46. // 确认按钮
  47. function modalSure() {
  48. if (iedValue.value == '') {
  49. ElMessage({
  50. message: "请输入正确的编码",
  51. type: "error"
  52. })
  53. } else {
  54. flow.updateIedType({
  55. id: modelType.value - 0,
  56. old_iedtype: "",
  57. new_iedtype: iedValue.value
  58. }).then(res => {
  59. if (res.code == 0) {
  60. ElMessage({
  61. message: "添加成功",
  62. type: "success"
  63. })
  64. dialogVisible.value = false
  65. emit("groupBack", dialogVisible.value)
  66. } else {
  67. ElMessage({
  68. message: res.msg,
  69. type: "error"
  70. })
  71. }
  72. })
  73. }
  74. }
  75. onMounted(() => {
  76. reload()
  77. })
  78. return {
  79. reload,//初始化组件函数
  80. handleClose: modalClose,//关闭模态框函数替代关闭函数
  81. cancels: modalClose,//关闭模态框函数替代关闭函数
  82. sureClick: modalSure,//确认按钮函数替代确认函数
  83. iedValue,//输入框value值
  84. dialogVisible,//模态框状态
  85. modelType,//本组件的模型id
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped></style>