banzhengXinxi.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="form-container">
  3. <!-- 报证机构(picker 实现下拉选择) -->
  4. <view class="form-item">
  5. <text class="label">* 报证机构:</text>
  6. <picker mode="selector" :range="jigouNames" @change="jigouChange">
  7. <view class="picker">
  8. {{ formData.baozhengJigouName || '请选择报证机构' }}
  9. </view>
  10. </picker>
  11. </view>
  12. <!-- 职业名称(picker 实现下拉选择) -->
  13. <view class="form-item">
  14. <text class="label">* 职业名称:</text>
  15. <picker mode="selector" :range="zhiyeNames" range-key="name" @change="zhiyeChange">
  16. <view class="picker">
  17. {{ formData.zhiyeName || '请选择职业名称' }}
  18. </view>
  19. </picker>
  20. </view>
  21. <!-- 职业等级(picker 实现下拉选择) -->
  22. <view class="form-item">
  23. <text class="label">* 职业等级:</text>
  24. <picker mode="selector" :range="zhiyeLevels" @change="levelChange">
  25. <view class="picker">
  26. {{ formData.zhiyeLevelName || '请选择等级' }}
  27. </view>
  28. </picker>
  29. </view>
  30. <view v-if="formData.banzhengInfoFlag" class="form-item">
  31. <text class="label">参训时间:</text>
  32. <uni-datetime-picker v-model="formData.canxunShijian" type="date" @change="canxunShijianChange">
  33. <view class="list-row">
  34. <icon class="list-icon error-icon"></icon>
  35. <text>{{formData.canxunShijian}}</text>
  36. </view>
  37. </uni-datetime-picker>
  38. </view>
  39. <view v-if="formData.banzhengInfoFlag" class="form-item">
  40. <view>*实操成绩</view>
  41. <input v-model="formData.shicaochengji" placeholder="请填写实操成绩" />
  42. </view>
  43. <view v-if="formData.banzhengInfoFlag" class="form-item">
  44. <view>*总课时</view>
  45. <input v-model="formData.zongkeshi" placeholder="请填写总课时" />
  46. </view>
  47. <view v-if="!formData.banzhengInfoFlag" class="form-item">
  48. <text class="label">需要课程:</text>
  49. <radio-group @change="kechengChange">
  50. <label class="radio-label">
  51. <radio :value="'true'" :checked="formData.needKecheng == 'true'" />
  52. <text>是</text>
  53. </label>
  54. <label class="radio-label">
  55. <radio :value="'false'" :checked="formData.needKecheng == 'false'" />
  56. <text>否</text>
  57. </label>
  58. </radio-group>
  59. </view>
  60. <view v-if="!formData.banzhengInfoFlag" class="form-item">
  61. <text class="label">需要考试:</text>
  62. <radio-group @change="kaoshiChange">
  63. <label class="radio-label">
  64. <radio :value="'true'" :checked="formData.needKaoshi == 'true'" />
  65. <text>是</text>
  66. </label>
  67. <label class="radio-label">
  68. <radio :value="'false'" :checked="formData.needKaoshi == 'false'" />
  69. <text>否</text>
  70. </label>
  71. </radio-group>
  72. </view>
  73. <!-- 提交按钮 -->
  74. <!-- <button class="submit-btn" @click="submitForm">提交</button> -->
  75. </view>
  76. </template>
  77. <script>
  78. import {
  79. getBaozhengJigou,
  80. getJiazhengLevel,
  81. getJiazhengZhiye
  82. } from "@/api/jiazheng.js"
  83. export default {
  84. data() {
  85. return {
  86. formData: {
  87. baozhengJigouId: '',
  88. baozhengJigouName: '',
  89. baozhengJigouType: '',
  90. banzhengInfoFlag: false,
  91. zhiyeName: '',
  92. zhiyeId: '',
  93. zhiyeLevelName: '',
  94. zhiyeLevelId: '',
  95. canxunShijian: '',
  96. shicaochengji: '',
  97. zongkeshi: '',
  98. needKecheng: 'false', // 默认选中"是"
  99. needKaoshi: 'false' // 默认选中"是"
  100. },
  101. baozhengJigouOpt: [
  102. ],
  103. zhiyelevelsOpt: [],
  104. zhiyeNameOpt: [
  105. ]
  106. };
  107. },
  108. computed: {
  109. jigouNames() {
  110. return this.baozhengJigouOpt.map(item => item.name);
  111. },
  112. zhiyeNames() {
  113. return this.zhiyeNameOpt.map(item => item.name);
  114. },
  115. zhiyeLevels() {
  116. return this.zhiyelevelsOpt.map(item => item.name);
  117. },
  118. },
  119. created() {
  120. this.getJigou()
  121. },
  122. methods: {
  123. getJigou() {
  124. getBaozhengJigou({}).then(res => {
  125. console.log('res', res);
  126. this.baozhengJigouOpt = res.data
  127. })
  128. },
  129. getZhiye() {
  130. this.zhiyeNameOpt = []
  131. this.formData.zhiyeName = ''
  132. this.formData.zhiyeId = ''
  133. getJiazhengZhiye({
  134. id: this.formData.baozhengJigouId
  135. }).then(res => {
  136. console.log('res', res);
  137. this.zhiyeNameOpt = res.data
  138. })
  139. },
  140. getZhiyeLevel() {
  141. this.zhiyelevelsOpt = []
  142. this.formData.zhiyeLevelName = ''
  143. this.formData.zhiyeLevelId = ''
  144. let req = {
  145. jgId: this.formData.baozhengJigouId,
  146. zyId: this.formData.zhiyeId
  147. }
  148. getJiazhengLevel(req).then(res => {
  149. console.log('res', res);
  150. this.zhiyelevelsOpt = res.data
  151. })
  152. },
  153. // 报证机构选择
  154. jigouChange(e) {
  155. this.formData.baozhengJigouName = this.baozhengJigouOpt[e.detail.value].name;
  156. this.formData.baozhengJigouId = this.baozhengJigouOpt[e.detail.value].jgId;
  157. this.formData.baozhengJigouType = this.baozhengJigouOpt[e.detail.value].jgType;
  158. this.formData.banzhengInfoFlag = this.baozhengJigouOpt[e.detail.value].jgType == 1;
  159. if (this.formData.banzhengInfoFlag) {
  160. this.formData.needKaoshi = 'false'
  161. this.formData.needKecheng = 'false'
  162. } else {
  163. this.formData.needKaoshi = 'true'
  164. this.formData.needKecheng = 'false'
  165. }
  166. this.getZhiye()
  167. },
  168. // 职业等级选择
  169. levelChange(e) {
  170. this.formData.zhiyeLevelId = this.zhiyelevelsOpt[e.detail.value].id;
  171. this.formData.zhiyeLevelName = this.zhiyelevelsOpt[e.detail.value].name;
  172. },
  173. // 职业名称选择
  174. zhiyeChange(e) {
  175. this.formData.zhiyeName = this.zhiyeNameOpt[e.detail.value].name;
  176. this.formData.zhiyeId = this.zhiyeNameOpt[e.detail.value].id;
  177. this.getZhiyeLevel()
  178. },
  179. canxunShijianChange(e) {
  180. console.log('e', e);
  181. this.formData.canxunShijian = e
  182. },
  183. // 需要课程选择
  184. kechengChange(e) {
  185. console.log('e', e);
  186. this.formData.needKecheng = e.detail.value.toString();
  187. },
  188. // 需要考试选择
  189. kaoshiChange(e) {
  190. this.formData.needKaoshi = e.detail.value.toString();
  191. },
  192. // 提交表单
  193. submitForm() {
  194. // 表单验证
  195. if (!this.formData.institution) {
  196. uni.showToast({
  197. title: '请选择报证机构',
  198. icon: 'none'
  199. });
  200. return;
  201. }
  202. if (!this.formData.selectedLevel) {
  203. uni.showToast({
  204. title: '请选择职业等级',
  205. icon: 'none'
  206. });
  207. return;
  208. }
  209. if (!this.formData.selectedOccupation) {
  210. uni.showToast({
  211. title: '请选择职业名称',
  212. icon: 'none'
  213. });
  214. return;
  215. }
  216. // 提交数据(示例)
  217. console.log('提交数据:', this.formData);
  218. uni.showToast({
  219. title: '提交成功'
  220. });
  221. }
  222. }
  223. };
  224. </script>
  225. <style scoped>
  226. .form-container {
  227. padding: 30rpx;
  228. background-color: #f8f8f8;
  229. min-height: 100vh;
  230. }
  231. .form-item {
  232. background-color: #fff;
  233. padding: 30rpx;
  234. margin-bottom: 30rpx;
  235. border-radius: 12rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. }
  240. .label {
  241. font-size: 28rpx;
  242. color: #333;
  243. width: 200rpx;
  244. }
  245. .picker {
  246. flex: 1;
  247. font-size: 28rpx;
  248. color: #999;
  249. text-align: right;
  250. }
  251. .radio-label {
  252. margin-left: 40rpx;
  253. display: inline-flex;
  254. align-items: center;
  255. }
  256. .radio-label text {
  257. margin-left: 10rpx;
  258. font-size: 28rpx;
  259. }
  260. .submit-btn {
  261. margin-top: 60rpx;
  262. background-color: #007aff;
  263. color: #fff;
  264. border-radius: 50rpx;
  265. }
  266. /* 选中样式 */
  267. radio[checked] .wx-radio-input {
  268. background-color: #007aff !important;
  269. border-color: #007aff !important;
  270. }
  271. </style>