project-setting.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {NButton, NForm, NFormItemGi, NGrid, NIcon, NInput, NTooltip, useMessage} from 'naive-ui'
  2. import {defineComponent, onMounted, reactive, ref} from 'vue'
  3. import {sysParamConfigQueryByParamName, sysParamConfigUpdate} from "@views/system-manage/param-settings/api";
  4. import {HelpCircleOutline} from "@vicons/ionicons5";
  5. export default defineComponent({
  6. name: 'project-param-setting',
  7. props: {
  8. appKey: {
  9. type: String,
  10. default: 'KT'
  11. }
  12. },
  13. setup(props) {
  14. const forms = reactive({
  15. id: null as any,
  16. paramValue: null as any,
  17. group: null as any,
  18. }) as any
  19. const formsRef = ref()
  20. const btnLoading = ref(false)
  21. const message = useMessage()
  22. const paramName = (() => {
  23. return props.appKey.toLowerCase() + '_frequency' as any
  24. })
  25. onMounted(async () => {
  26. const {data} = await sysParamConfigQueryByParamName(paramName());
  27. if (data) {
  28. forms.id = data.id
  29. forms.paramValue = data.paramValue
  30. forms.group = data.group
  31. } else {
  32. message.error("加载配置参数失败");
  33. }
  34. })
  35. const onSubmit = async () => {
  36. const param = {
  37. group: forms.group,
  38. configs: [
  39. {
  40. ...forms
  41. }
  42. ]
  43. }
  44. btnLoading.value = true
  45. try {
  46. const res = await sysParamConfigUpdate(param) as any
  47. if (res && res.code == '200') {
  48. message.success('保存成功')
  49. }
  50. } catch (err) {
  51. }
  52. btnLoading.value = false
  53. }
  54. return () => (
  55. <>
  56. <NForm labelPlacement="left" model={forms} requireMarkPlacement="left" ref={formsRef}>
  57. <NGrid cols={1}>
  58. <NFormItemGi
  59. label="评测频率"
  60. path="scope_of_attendance"
  61. rule={[
  62. {
  63. required: false,
  64. message: '请输入评测频率',
  65. trigger: ['blur', 'input']
  66. }
  67. ]}
  68. >
  69. <NInput
  70. v-model:value={forms.paramValue}
  71. placeholder="请输入评测频率"
  72. clearable
  73. style="width:200px"
  74. />
  75. <NTooltip style={"padding-left: 10px"}>
  76. {{
  77. default: () => '评测频率支持输入多个,输入多个时需要逗号隔开',
  78. trigger: () => (
  79. <span style="overflow: hidden;display: inline-block;max-width: 200px;white-space: nowrap;text-overflow: ellipsis;">
  80. <NIcon size="20">
  81. <HelpCircleOutline/>
  82. </NIcon>
  83. </span>
  84. )
  85. }}
  86. </NTooltip>
  87. </NFormItemGi>
  88. </NGrid>
  89. </NForm>
  90. <NButton
  91. type="primary"
  92. onClick={onSubmit}
  93. loading={btnLoading.value}
  94. //v-auth="sysParamConfig/update1597903049401421825"
  95. >
  96. 保存设置
  97. </NButton>
  98. </>
  99. )
  100. }
  101. })