index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="uni-container">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 85) + 'px'">
  4. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="100%" labelAlign="left">
  5. <view class="juli-bottom">
  6. <u-form-item label="所属单位" prop="orgName" @click="showOrg = true; hideKeyboard()">
  7. <u-input v-model="formData.orgName" placeholder="请输入" :disabled="isview" />
  8. </u-form-item>
  9. <u-form-item label="人员姓名" prop="empName" :required="true">
  10. <u-input v-model="formData.empName" placeholder="请输入" :disabled="isview" />
  11. </u-form-item>
  12. <u-form-item label="特种证书编号" prop="numberCode" :required="true">
  13. <u-input v-model="formData.numberCode" placeholder="请输入" :disabled="isview" />
  14. </u-form-item>
  15. <u-form-item label="身份证号" prop="idcardno" :required="true">
  16. <u-input v-model="formData.idcardno" placeholder="请输入" :disabled="isview" />
  17. </u-form-item>
  18. <u-form-item label="性别" prop="empGender" @click="showSex = true; hideKeyboard()">
  19. <u-input v-model="formData.empGender" placeholder="请选择" :disabled="isview" />
  20. </u-form-item>
  21. <picker mode="date" :value="dateTime" @change="bindDateChange" :disabled="isview">
  22. <view class="datatime-street">
  23. <u-form-item label="人员出生日期" prop="empBirthday">
  24. <u-input v-model="formData.empBirthday" placeholder="人员出生日期" class="add-date"
  25. :disabled="isview" />
  26. </u-form-item>
  27. </view>
  28. </picker>
  29. <picker mode="date" @change="bindDateChange2" :disabled="isview">
  30. <view class="datatime-street">
  31. <u-form-item label="颁证时间" prop="issueDate">
  32. <u-input v-model="formData.issueDate" placeholder="颁证时间" class="add-date"
  33. :disabled="isview" />
  34. </u-form-item>
  35. </view>
  36. </picker>
  37. </view>
  38. </u--form>
  39. </view>
  40. <view class="heigthButton">
  41. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  42. color="#4CB2B6" text="确认修改" style="width:200px">
  43. </u-button>
  44. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  45. color="#4CB2B6" text="确认新增" style="width:200px">
  46. </u-button>
  47. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  48. color="#4CB2B6" text="返回" style="width:200px">
  49. </u-button>
  50. </view>
  51. <u-action-sheet :show="showSex" :actions="actionsSex" title="请选择性别" @close="showSex = false"
  52. @select="sexSelect">
  53. </u-action-sheet>
  54. <u-action-sheet :show="showOrg" :actions="orgaction" title="请选择单位" class="org-choice" @close="showOrg = false"
  55. @select="orgSelect"></u-action-sheet>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. fireSpecialUpdate,
  61. fireSpecialCreate,
  62. fireSpecialIdGet
  63. } from '@/api/fireSpecial';
  64. import {
  65. NumericRule
  66. } from '@/utils/common.js';
  67. import config from '@/config'
  68. import {
  69. DICT_TYPE,
  70. getDictDatas
  71. } from "@/utils/dict";
  72. const baseUrlImg = config.baseUrlImg
  73. export default {
  74. data() {
  75. return {
  76. screenHeight: this.$screenHeight,
  77. wheight: '',
  78. formData: {
  79. orgName: '',
  80. orgId: '',
  81. empName: '',
  82. numberCode: '',
  83. idcardno: '',
  84. empGender: '',
  85. empBirthday: '',
  86. issueDate: ''
  87. },
  88. rules: {
  89. empName: [{
  90. type: 'string',
  91. required: true,
  92. message: '人员姓名不能为空',
  93. trigger: ['blur', 'change']
  94. }],
  95. numberCode: [{
  96. type: 'string',
  97. required: true,
  98. message: '特种证书编号',
  99. trigger: ['blur', 'change']
  100. }],
  101. idcardno: [{
  102. type: 'string',
  103. required: true,
  104. pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
  105. message: "请输入合法身份证号",
  106. trigger: ['blur', 'change']
  107. }],
  108. // empName: NumericRule(),
  109. },
  110. isedit: '',
  111. isview: '',
  112. dateTime: '',
  113. showSex: false,
  114. actionsSex: getDictDatas(DICT_TYPE.SYSTEM_USER_SEX), //性别
  115. orgaction: [], //单位
  116. showOrg: false
  117. }
  118. },
  119. onReady() {
  120. this.$refs.customForm.setRules(this.rules);
  121. },
  122. mounted() {
  123. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  124. this.wheight = data.height
  125. }).exec()
  126. },
  127. onLoad(option) {
  128. this.formData.orgName = option.orgName ? option.orgName : ''
  129. this.formData.orgId = option.orgId ? option.orgId : ''
  130. this.orgaction = option.orgaction ? JSON.parse(option.orgaction) : []
  131. this.actionsSex.map(i => i.name = i.label)
  132. uni.setNavigationBarTitle({
  133. title: option.title
  134. })
  135. if (option.editData) {
  136. this.isedit = true
  137. this.isview = false
  138. this.parentId = option.editData
  139. this.getData()
  140. // this.formData = JSON.parse(option.editData)
  141. } else if (option.viewData) {
  142. this.isview = true
  143. this.parentId = option.viewData
  144. this.getData()
  145. // this.formData = JSON.parse(option.viewData)
  146. } else {
  147. this.isedit = false
  148. this.isview = false
  149. }
  150. console.log(this.isedit,'ffffffff',this.isview);
  151. },
  152. methods: {
  153. sexSelect(e) {
  154. this.formData.empGender = e.name
  155. },
  156. orgSelect(e) {
  157. this.formData.orgName = e.name
  158. this.formData.orgId = e.value
  159. },
  160. hideKeyboard() {
  161. uni.hideKeyboard()
  162. },
  163. getData() {
  164. fireSpecialIdGet({
  165. id: this.parentId
  166. }).then(response => {
  167. this.formData = response.data
  168. console.log(response, 'response')
  169. })
  170. },
  171. //拍照
  172. closeImage(val, index) {
  173. this.formData.streetRepPicsDOList.splice(index, 1)
  174. },
  175. bindDateChange(e) {
  176. this.formData.empBirthday = e.detail.value
  177. },
  178. bindDateChange2(e) {
  179. this.formData.issueDate = e.detail.value
  180. },
  181. submit(ref) {
  182. this.$refs[ref].validate().then(res => {
  183. console.log(this.isview, 'this.formDatathis.isview');
  184. if (this.isedit) {
  185. fireSpecialUpdate(JSON.stringify(this.formData)).then(res => {
  186. this.$modal.msg('修改成功')
  187. this.isedit = false
  188. setTimeout(() => {
  189. uni.navigateBack()
  190. }, 400)
  191. })
  192. } else if (this.isview) {
  193. this.isview = false
  194. uni.navigateBack()
  195. } else {
  196. fireSpecialCreate(JSON.stringify(this.formData)).then(response => {
  197. this.$modal.msg('新增成功')
  198. setTimeout(() => {
  199. uni.navigateBack()
  200. }, 400)
  201. })
  202. }
  203. }).catch(err => {
  204. console.log(err);
  205. })
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. body {
  212. background-color: #f5f7f9;
  213. }
  214. page {
  215. background-color: #f5f7f9 !important;
  216. }
  217. .uni-container {
  218. // height: 100vh;
  219. background-color: #f5f7f9 !important;
  220. }
  221. /deep/.uni-card {
  222. position: relative;
  223. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  224. border-radius: 30rpx;
  225. }
  226. .example {
  227. overflow-y: auto;
  228. }
  229. .juli-bottom {
  230. /deep/ .u-form-item__body__left__content__label {
  231. color: #000 !important;
  232. }
  233. }
  234. .org-choice {
  235. /deep/.u-action-sheet {
  236. overflow-y: auto;
  237. height: 1000rpx;
  238. background-color: #fff;
  239. }
  240. }
  241. </style>