banzhengXinxi.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. <view>
  74. <view>上一步</view>
  75. <view>完成</view>
  76. </view>
  77. <!-- 提交按钮 -->
  78. <!-- <button class="submit-btn" @click="submitForm">提交</button> -->
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. getBaozhengJigou,
  84. getJiazhengLevel,
  85. getJiazhengZhiye
  86. } from "@/api/jiazheng.js"
  87. export default {
  88. data() {
  89. return {
  90. formData: {
  91. baozhengJigouId: '',
  92. baozhengJigouName: '',
  93. baozhengJigouType: '',
  94. banzhengInfoFlag: false,
  95. zhiyeName: '',
  96. zhiyeId: '',
  97. zhiyeLevelName: '',
  98. zhiyeLevelId: '',
  99. canxunShijian: '',
  100. shicaochengji: '',
  101. zongkeshi: '',
  102. needKecheng: 'false', // 默认选中"是"
  103. needKaoshi: 'false' // 默认选中"是"
  104. },
  105. baozhengJigouOpt: [
  106. ],
  107. zhiyelevelsOpt: [],
  108. zhiyeNameOpt: [
  109. ]
  110. };
  111. },
  112. computed: {
  113. jigouNames() {
  114. return this.baozhengJigouOpt.map(item => item.name);
  115. },
  116. zhiyeNames() {
  117. return this.zhiyeNameOpt.map(item => item.name);
  118. },
  119. zhiyeLevels() {
  120. return this.zhiyelevelsOpt.map(item => item.name);
  121. },
  122. },
  123. created() {
  124. this.getJigou()
  125. },
  126. methods: {
  127. getJigou() {
  128. getBaozhengJigou({}).then(res => {
  129. console.log('res', res);
  130. this.baozhengJigouOpt = res.data
  131. })
  132. },
  133. getZhiye() {
  134. this.zhiyeNameOpt = []
  135. this.formData.zhiyeName = ''
  136. this.formData.zhiyeId = ''
  137. getJiazhengZhiye({
  138. id: this.formData.baozhengJigouId
  139. }).then(res => {
  140. console.log('res', res);
  141. this.zhiyeNameOpt = res.data
  142. })
  143. },
  144. getZhiyeLevel() {
  145. this.zhiyelevelsOpt = []
  146. this.formData.zhiyeLevelName = ''
  147. this.formData.zhiyeLevelId = ''
  148. let req = {
  149. jgId: this.formData.baozhengJigouId,
  150. zyId: this.formData.zhiyeId
  151. }
  152. getJiazhengLevel(req).then(res => {
  153. console.log('res', res);
  154. this.zhiyelevelsOpt = res.data
  155. })
  156. },
  157. // 报证机构选择
  158. jigouChange(e) {
  159. this.formData.baozhengJigouName = this.baozhengJigouOpt[e.detail.value].name;
  160. this.formData.baozhengJigouId = this.baozhengJigouOpt[e.detail.value].jgId;
  161. this.formData.baozhengJigouType = this.baozhengJigouOpt[e.detail.value].jgType;
  162. this.formData.banzhengInfoFlag = this.baozhengJigouOpt[e.detail.value].jgType == 1;
  163. if (this.formData.banzhengInfoFlag) {
  164. this.formData.needKaoshi = 'false'
  165. this.formData.needKecheng = 'false'
  166. } else {
  167. this.formData.needKaoshi = 'true'
  168. this.formData.needKecheng = 'false'
  169. }
  170. this.getZhiye()
  171. },
  172. // 职业等级选择
  173. levelChange(e) {
  174. this.formData.zhiyeLevelId = this.zhiyelevelsOpt[e.detail.value].id;
  175. this.formData.zhiyeLevelName = this.zhiyelevelsOpt[e.detail.value].name;
  176. },
  177. // 职业名称选择
  178. zhiyeChange(e) {
  179. this.formData.zhiyeName = this.zhiyeNameOpt[e.detail.value].name;
  180. this.formData.zhiyeId = this.zhiyeNameOpt[e.detail.value].id;
  181. this.getZhiyeLevel()
  182. },
  183. canxunShijianChange(e) {
  184. console.log('e', e);
  185. this.formData.canxunShijian = e
  186. },
  187. // 需要课程选择
  188. kechengChange(e) {
  189. console.log('e', e);
  190. this.formData.needKecheng = e.detail.value.toString();
  191. },
  192. // 需要考试选择
  193. kaoshiChange(e) {
  194. this.formData.needKaoshi = e.detail.value.toString();
  195. },
  196. // 提交表单
  197. submitForm() {
  198. // 表单验证
  199. if (!this.formData.institution) {
  200. uni.showToast({
  201. title: '请选择报证机构',
  202. icon: 'none'
  203. });
  204. return;
  205. }
  206. if (!this.formData.selectedLevel) {
  207. uni.showToast({
  208. title: '请选择职业等级',
  209. icon: 'none'
  210. });
  211. return;
  212. }
  213. if (!this.formData.selectedOccupation) {
  214. uni.showToast({
  215. title: '请选择职业名称',
  216. icon: 'none'
  217. });
  218. return;
  219. }
  220. // 提交数据(示例)
  221. console.log('提交数据:', this.formData);
  222. uni.showToast({
  223. title: '提交成功'
  224. });
  225. }
  226. }
  227. };
  228. </script>
  229. <style scoped>
  230. .form-container {
  231. padding: 30rpx;
  232. background-color: #f8f8f8;
  233. min-height: 100vh;
  234. }
  235. .form-item {
  236. background-color: #fff;
  237. padding: 30rpx;
  238. margin-bottom: 30rpx;
  239. border-radius: 12rpx;
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. }
  244. .label {
  245. font-size: 28rpx;
  246. color: #333;
  247. width: 200rpx;
  248. }
  249. .picker {
  250. flex: 1;
  251. font-size: 28rpx;
  252. color: #999;
  253. text-align: right;
  254. }
  255. .radio-label {
  256. margin-left: 40rpx;
  257. display: inline-flex;
  258. align-items: center;
  259. }
  260. .radio-label text {
  261. margin-left: 10rpx;
  262. font-size: 28rpx;
  263. }
  264. .submit-btn {
  265. margin-top: 60rpx;
  266. background-color: #007aff;
  267. color: #fff;
  268. border-radius: 50rpx;
  269. }
  270. /* 选中样式 */
  271. radio[checked] .wx-radio-input {
  272. background-color: #007aff !important;
  273. border-color: #007aff !important;
  274. }
  275. </style>