You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <t-form
  3. :data="formData"
  4. :rules="pubRules"
  5. ref="form"
  6. @reset="onReset"
  7. @submit="onSubmit"
  8. >
  9. <t-form-item
  10. label="任务名称"
  11. help="任务名称用来直观的说明本次操作"
  12. name="taskName"
  13. >
  14. <t-input
  15. v-model="formData.taskName"
  16. placeholder="请输入任务名称"
  17. ></t-input>
  18. </t-form-item>
  19. <t-form-item label="核查顺序" name="checkOrder">
  20. <t-radio-group v-model="formData.checkOrder">
  21. <t-radio value="0">横向</t-radio>
  22. <t-radio value="1">纵向</t-radio>
  23. </t-radio-group>
  24. </t-form-item>
  25. <t-form-item label="核电站" name="nuclearStationId">
  26. <t-select
  27. v-model="formData.nuclearStationId"
  28. class="demo-select-base"
  29. clearable
  30. filterable
  31. @change="handleStationChange"
  32. placeholder="请选择所在核电站"
  33. >
  34. <t-option
  35. v-for="item in stationList"
  36. :value="item.id"
  37. :label="item.name"
  38. :key="item.id"
  39. >
  40. {{ item.name }}
  41. </t-option>
  42. </t-select>
  43. </t-form-item>
  44. <t-form-item label="堆芯" name="nuclearCoreId">
  45. <t-select
  46. v-model="formData.nuclearCoreId"
  47. class="demo-select-base"
  48. clearable
  49. filterable
  50. placeholder="请选择所在堆芯"
  51. >
  52. <t-option
  53. v-for="item in coreList"
  54. :value="item.id"
  55. :label="item.name"
  56. :key="item.id"
  57. >
  58. {{ item.name }}
  59. </t-option>
  60. </t-select>
  61. </t-form-item>
  62. <t-form-item label="操作员" name="operatorId">
  63. <t-select
  64. v-model="formData.operatorId"
  65. class="demo-select-base"
  66. clearable
  67. filterable
  68. placeholder="请选择分配的操作员"
  69. >
  70. <t-option
  71. v-for="item in userList"
  72. :value="item.username"
  73. :label="item.nickname"
  74. :key="item.id"
  75. >
  76. {{ item.nickname }}
  77. </t-option>
  78. </t-select>
  79. </t-form-item>
  80. <t-form-item>
  81. <t-space size="10px">
  82. <t-button theme="primary" type="submit">提交</t-button>
  83. <t-button theme="default" variant="base" type="reset">重置</t-button>
  84. </t-space>
  85. </t-form-item>
  86. </t-form>
  87. </template>
  88. <script>
  89. import { allOperatorApi } from '@/api/publish'
  90. import { createTaskApi } from '@/api/task'
  91. import { useAccountStore } from '@/store'
  92. import { stationListApi, coreListByStationIdApi } from '@/api/info'
  93. const accountStore = useAccountStore()
  94. const INITIAL_DATA = {
  95. taskName: '',
  96. checkOrder: '',
  97. nuclearStationId: '',
  98. nuclearCoreId: '',
  99. operatorId: '',
  100. }
  101. export default {
  102. data() {
  103. return {
  104. formData: { ...INITIAL_DATA },
  105. stationList: [],
  106. userList: [],
  107. coreList: [],
  108. pubRules: {
  109. taskName: [{ required: true, message: '请填写任务名称' }],
  110. operatorId: [{ required: true, message: '请选择要分配的操作员' }],
  111. nuclearCoreId: [{ required: true, message: '请选择堆芯' }],
  112. nuclearStationId: [{ required: true, message: '请选择核电站' }],
  113. checkOrder: [{ required: true, message: '核查路径顺序必填' }],
  114. },
  115. }
  116. },
  117. methods: {
  118. async handleStationChange(value, context) {
  119. const res = await coreListByStationIdApi(value)
  120. if (res?.code == 200) {
  121. this.coreList = res?.data.list
  122. }
  123. },
  124. async getStationList() {
  125. const res = await stationListApi()
  126. if (res?.code == 200) {
  127. this.stationList = res?.data?.list
  128. }
  129. },
  130. async getAllOperator() {
  131. const res = await allOperatorApi()
  132. if (res?.code == 200) {
  133. this.userList = res?.data
  134. }
  135. },
  136. onReset() {
  137. this.$message.success('重置成功')
  138. },
  139. async onSubmit({ validateResult, firstError }) {
  140. if (validateResult === true) {
  141. const res = await createTaskApi(this.formData)
  142. if (res?.code == 200) {
  143. if (res?.data?.result) {
  144. this.$message.success('创建任务成功')
  145. accountStore.changePage(1)
  146. }
  147. }
  148. } else {
  149. this.$message.warning(firstError)
  150. }
  151. },
  152. },
  153. mounted() {
  154. this.getAllOperator()
  155. this.getStationList()
  156. },
  157. }
  158. </script>
  159. <style scoped></style>