parameterSetting.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="parameter-setting-container">
  3. <el-collapse v-model="activeNames" @change="handleChange">
  4. <el-collapse-item v-for="(subject, index) in subjectInfos" :key="index" :name="index + ''">
  5. <template slot="title">
  6. <span class="collapse-title">{{ subject.name }}</span>
  7. </template>
  8. <div v-if="showTools" class="flex-row top-btn">
  9. <el-button type="primary" size="mini" @click="addParam(subject, index)">新增</el-button>
  10. </div>
  11. <el-table
  12. :header-cell-style="{ background: '#F6F7FB', color: '#606266' }"
  13. :data="subject.options"
  14. border
  15. style="width: 100%;"
  16. >
  17. <el-table-column prop="name" label="名称" min-width="3">
  18. <template slot-scope="scope">
  19. {{ scope.row.name }}
  20. <template v-if="scope.row.remaks && scope.row.remaks.length > 0">
  21. {{ scope.row.remaks }}
  22. </template>
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="code" label="编码" min-width="1" />
  26. <el-table-column prop="value" label="值" min-width="2" >
  27. <template slot-scope="scope">
  28. <el-input v-model="scope.row.value" placeholder="请输入参数值" @change="editParam(scope.row)"></el-input>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. </el-collapse-item>
  33. </el-collapse>
  34. <el-dialog
  35. :title="dialogTitle"
  36. :visible.sync="dialogVisible"
  37. width="40%"
  38. append-to-body
  39. >
  40. <el-form :model="form" :rules="rules" ref="ruleForm" label-width="160px">
  41. <el-form-item label="参数名称" prop="name">
  42. <el-input v-model="form.name" placeholder="请输入参数名称"></el-input>
  43. </el-form-item>
  44. <el-form-item label="参数编码" prop="name">
  45. <el-input v-model="form.code" placeholder="请输入参数编码(确认后不可更改)"></el-input>
  46. </el-form-item>
  47. <el-form-item label="值" prop="name">
  48. <el-input v-model="form.value" placeholder="请输入参数值"></el-input>
  49. </el-form-item>
  50. <el-form-item label="备注" prop="remarks">
  51. <el-input v-model="form.remarks" placeholder="请输入备注"></el-input>
  52. </el-form-item>
  53. </el-form>
  54. <span slot="footer" class="dialog-footer">
  55. <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
  56. <el-button size="mini" type="primary" @click="addParamFn">确 定</el-button>
  57. </span>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script>
  62. export default {
  63. name: "ReportMgr",
  64. data() {
  65. return {
  66. activeNames: [],
  67. subjectInfos: [],
  68. loading: false,
  69. uId: '',
  70. institutionNo: '',
  71. dialogTitle: '',
  72. dialogVisible: false,
  73. targetSubject: {},
  74. targetIndex: -1,
  75. form: {
  76. id: null, // 数据ID
  77. taskId: '', // 认知任务ID
  78. code: '', // 参数编码
  79. name: '', // 参数名称
  80. value: '', // 参数值
  81. remarks: '' // 备注
  82. },
  83. rules: {
  84. name: [
  85. { required: true, message: '请输入参数名称', trigger: 'blur' }
  86. ],
  87. code: [
  88. { required: true, message: '请输入参数编码', trigger: 'blur' }
  89. ],
  90. value: [
  91. { required: true, message: '请输入参数值', trigger: 'blur' }
  92. ]
  93. },
  94. showTools: false
  95. }
  96. },
  97. mounted() {
  98. this.showTools = process.env.NODE_ENV === 'development'
  99. this.loadData()
  100. },
  101. methods: {
  102. handleChange(val) {
  103. val.forEach((item) => {
  104. this.$http.get(
  105. `/taskParam/getByTaskId?taskId=${this.subjectInfos[Number(item)].id}`,
  106. {},
  107. (msg) => {
  108. this.subjectInfos[Number(item)].options = msg.data
  109. console.log('this.subjectInfos[Number(item)].options: ', this.subjectInfos[Number(item)].options)
  110. }
  111. )
  112. })
  113. },
  114. // 加载数据
  115. loadData() {
  116. this.loading = true
  117. this.$http.get(
  118. `subjectInfo/getCognizeListByName?categoryEname=CALL&scaleName=&pageNum=1&pageSize=100`,
  119. {},
  120. (msg) => {
  121. console.log(msg,'msg')
  122. this.subjectInfos = msg.data.data.filter((item) => ['空间定向任务', '精神运动警觉度测试', '时间知觉能力测试', '多目标追踪', '决策倾向测试'].includes(item.name)).map((item) => {
  123. return {
  124. id: item.no,
  125. name: item.name,
  126. isOpen: false,
  127. options: []
  128. }
  129. })
  130. console.log('')
  131. console.log('-----------------http start-------------------')
  132. console.log('this.subjectInfos: ', this.subjectInfos)
  133. console.log('-----------------http end-------------------')
  134. console.log('')
  135. setTimeout(() => {
  136. this.loading = false
  137. }, 350)
  138. }, (err) => {
  139. console.log(err)
  140. this.loading = false
  141. }
  142. )
  143. },
  144. /**
  145. * 新增参数
  146. * @param subject 当前 subjectInfos
  147. * @param index 当前索引
  148. */
  149. addParam(subject, index) {
  150. this.form = {
  151. id: null, // 数据ID
  152. taskId: subject.id, // 认知任务ID
  153. code: '', // 参数编码
  154. name: '', // 参数名称
  155. value: '', // 参数值
  156. remaks: '' // 备注
  157. }
  158. this.targetIndex = index
  159. this.dialogTitle = `${subject.name} 参数设置`
  160. this.dialogVisible = true
  161. },
  162. addParamFn() {
  163. this.$refs.ruleForm.validate((valid) => {
  164. if (valid) {
  165. this.$http.post(
  166. '/taskParam/save',
  167. this.form,
  168. () => {
  169. this.$message({
  170. message: '添加成功',
  171. type: 'success'
  172. })
  173. this.dialogVisible = false
  174. this.subjectInfos[this.targetIndex].options.push(this.form)
  175. },
  176. (err) => {
  177. this.$message.error('添加失败, ' + err.msg)
  178. }
  179. )
  180. }
  181. })
  182. },
  183. editParam(row) {
  184. console.log(row,'row')
  185. let params = {
  186. code:row.code,
  187. id:row.id,
  188. name:row.name,
  189. taskId:row.taskId,
  190. value:row.value
  191. }
  192. let valid = true;
  193. if (row.code == 'TTC_Target_Count' || row.code =='SOA_Target_Count') {
  194. console.log('TTC_Target_Count')
  195. const items = row.value.split(",");
  196. for (const item of items) {
  197. if (Number(item) > 5) {
  198. valid = false;
  199. break;
  200. }
  201. }
  202. }
  203. if (valid) {
  204. this.$http.post(
  205. '/taskParam/update',
  206. params,
  207. () => {
  208. console.log('修改成功!~')
  209. this.$message.success('修改成功')
  210. },
  211. (err) => {
  212. this.$message.error('修改失败, ' + err.msg)
  213. }
  214. )
  215. } else {
  216. console.log("字符串中有项大于 5");
  217. this.$message.error('修改失败,目标数量最大值不能超过5')
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .parameter-setting-container {
  225. width: calc(100% - 50px);
  226. height: calc(100% - 50px);
  227. padding: 15px 25px;
  228. border-radius: 8px;
  229. overflow: auto;
  230. background-color: white;
  231. .collapse-title {
  232. font-size: 0.08rem;
  233. color: #007EFF;
  234. }
  235. .top-btn {
  236. margin-bottom: 8px;
  237. }
  238. }
  239. </style>