GroupModelAdd.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. groupNodeId:{
  32. type:String,
  33. required: true,
  34. }//分组装置节点ID,确定时需要回传回画布界面
  35. },
  36. setup(props, { emit }) {
  37. let dialogVisible = ref(false)//模态框打开/关闭状态
  38. let iedValue = ref('')//输入框value值
  39. let modelType = ref("")//本组件的模型id
  40. // 初始化组件
  41. function reload() {
  42. dialogVisible.value = props.groupType
  43. modelType.value = props.modelId
  44. }
  45. // 关闭模态框
  46. function modalClose() {
  47. dialogVisible.value = false
  48. emit("groupBack", {"show":dialogVisible.value,'ied_type':'',"groupNodeId":props.groupNodeId})
  49. }
  50. // 确认按钮
  51. function modalSure() {
  52. const reg= /^[A-Za-z]+$/;
  53. const v = iedValue.value.replace(/ /g,'')
  54. if (v == '' || !reg.test(v)) {
  55. ElMessage({
  56. message: "请输入正确的组合装置编码:仅支持纯英文字母",
  57. type: "error"
  58. })
  59. } else {
  60. //仅更新本地编码,此处不需要提交到后台
  61. dialogVisible.value = false
  62. emit("groupBack", {"show":dialogVisible.value,"ied_type":v.toUpperCase(),"groupNodeId":props.groupNodeId})
  63. /*
  64. flow.updateIedType({
  65. id: modelType.value - 0,
  66. old_iedtype: "",
  67. new_iedtype: iedValue.value
  68. }).then(res => {
  69. if (res.code == 0) {
  70. ElMessage({
  71. message: "添加成功",
  72. type: "success"
  73. })
  74. dialogVisible.value = false
  75. emit("groupBack", dialogVisible.value)
  76. } else {
  77. ElMessage({
  78. message: res.msg,
  79. type: "error"
  80. })
  81. }
  82. })
  83. */
  84. }
  85. }
  86. //将输入的编码内容转为大写
  87. onMounted(() => {
  88. reload()
  89. })
  90. return {
  91. reload,//初始化组件函数
  92. handleClose: modalClose,//关闭模态框函数替代关闭函数
  93. cancels: modalClose,//关闭模态框函数替代关闭函数
  94. sureClick: modalSure,//确认按钮函数替代确认函数
  95. iedValue,//输入框value值
  96. dialogVisible,//模态框状态
  97. modelType,//本组件的模型id
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped></style>