addDoc.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <view class="form-item">
  6. <text class="label">姓名</text>
  7. <input maxlength="10" class="input-width" type="text" v-model="form.userName" placeholder="请如实填写您的真实姓名" placeholder-class="form-input" />
  8. </view>
  9. <view class="form-item">
  10. <text class="label">性别</text>
  11. <radio-group style="display: flex;align-items: center;">
  12. <label style="margin-right: 50upx;">
  13. <radio @click="sexChange(1)" value="1" :checked="form.sex===1" style="margin-right: 16upx;" />
  14. <text class="sex-text">男</text>
  15. </label>
  16. <label>
  17. <radio @click="sexChange(2)" value="2" :checked="form.sex===2" style="margin-right: 16upx;" />
  18. <text class="sex-text">女</text>
  19. </label>
  20. </radio-group>
  21. </view>
  22. <view class="form-item">
  23. <text class="label">身份证号</text>
  24. <input maxlength="18" class="input-width" type="idcard" v-model="form.idCard" placeholder="请如实填写身份证号" placeholder-class="form-input" />
  25. </view>
  26. <view class="form-item">
  27. <text class="label">出生年月</text>
  28. <picker class="birth-picker" mode="date" @change="bindDateChange">
  29. <view class="right-box">
  30. <view class="input-box">
  31. <input type="text" :value="form.birthday" placeholder="请选择出生年月" placeholder-class="form-input" disabled="disabled" />
  32. </view>
  33. <image class="arrow" src="../../static/images/arrow_gray.png" mode=""></image>
  34. </view>
  35. </picker>
  36. </view>
  37. <view class="form-item">
  38. <text class="label">备注</text>
  39. <textarea maxlength="200" class="form-textarea" v-model="form.remark" placeholder="请输入备注" />
  40. </view>
  41. </view>
  42. </view>
  43. <view class="btn-box">
  44. <view class="sub-btn" @click="submit()">保存档案</view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {getDocDetails,addDoc,editDoc} from '@/api/doc.js'
  50. export default {
  51. data() {
  52. return {
  53. type:null,
  54. patientId:null,
  55. form: {
  56. userName:null,
  57. idCard: null,
  58. sex:null,
  59. birthday:null,
  60. remark:null,
  61. }
  62. };
  63. },
  64. onLoad(option) {
  65. this.type=option.type;
  66. console.log(this.type)
  67. if(this.type=='edit'){
  68. this.docId=option.docId;
  69. this.getDocDetails();
  70. }
  71. },
  72. methods:{
  73. sexChange(type){
  74. this.form.sex=type
  75. },
  76. getDocDetails(){
  77. var data={docId:this.docId};
  78. getDocDetails(data).then(
  79. res => {
  80. if(res.code==200){
  81. this.form=res.data;
  82. }else{
  83. uni.showToast({
  84. title: res.msg,
  85. });
  86. }
  87. },
  88. rej => {}
  89. );
  90. },
  91. submit(){
  92. if(this.form.userName==null){
  93. uni.showToast({
  94. icon:'none',
  95. title: "姓名不能为空",
  96. });
  97. return;
  98. }
  99. if(this.form.idCard==null){
  100. uni.showToast({
  101. icon:'none',
  102. title: "身份证号不能为空",
  103. });
  104. return;
  105. }
  106. if(this.form.sex==null){
  107. uni.showToast({
  108. icon:'none',
  109. title: "性别不能为空",
  110. });
  111. return;
  112. }
  113. if(this.form.birthday==null){
  114. uni.showToast({
  115. icon:'none',
  116. title: "出生年月不能为空",
  117. });
  118. return;
  119. }
  120. if(this.type=="add"){
  121. this.addDoc()
  122. }
  123. else if(this.type=="edit"){
  124. this.editDoc()
  125. }
  126. },
  127. editDoc(){
  128. editDoc(this.form).then(
  129. res => {
  130. if(res.code==200){
  131. uni.showToast({
  132. icon:'success',
  133. title: "操作成功",
  134. });
  135. setTimeout(function() {
  136. uni.$emit('refreshDoc');
  137. uni.navigateBack({
  138. delta: 1
  139. })
  140. }, 500);
  141. }else{
  142. uni.showToast({
  143. icon:'none',
  144. title: res.msg,
  145. });
  146. }
  147. },
  148. rej => {}
  149. );
  150. },
  151. addDoc(){
  152. addDoc(this.form).then(
  153. res => {
  154. if(res.code==200){
  155. uni.showToast({
  156. icon:'success',
  157. title: "操作成功",
  158. });
  159. setTimeout(function() {
  160. uni.$emit('refreshDoc');
  161. uni.navigateBack({
  162. delta: 1
  163. })
  164. }, 500);
  165. }else{
  166. uni.showToast({
  167. icon:'none',
  168. title: res.msg,
  169. });
  170. }
  171. },
  172. rej => {}
  173. );
  174. },
  175. // 出生日期选择
  176. bindDateChange: function(e) {
  177. this.form.birthday = e.target.value
  178. },
  179. }
  180. }
  181. </script>
  182. <style lang="scss">
  183. page{
  184. height: 100%;
  185. }
  186. .content{
  187. height: 100%;
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: space-between;
  191. .inner{
  192. height: calc(100% - 120upx);
  193. padding: 20upx;
  194. .form-box{
  195. padding: 0 30upx;
  196. background: #FFFFFF;
  197. border-radius: 16upx;
  198. .form-item{
  199. padding: 30upx 0;
  200. display: flex;
  201. align-items: flex-start;
  202. border-bottom: 1px solid #F1F1F1;
  203. &:last-child{
  204. border-bottom: none;
  205. }
  206. .label{
  207. width: 150upx;
  208. text-align: left;
  209. font-size: 30upx;
  210. line-height: 44upx;
  211. font-family: PingFang SC;
  212. font-weight: 500;
  213. color: #222222;
  214. flex-shrink: 0;
  215. }
  216. input{
  217. text-align: left;
  218. }
  219. .form-input{
  220. font-size: 30upx;
  221. font-family: PingFang SC;
  222. font-weight: 500;
  223. color: #999999;
  224. text-align: left;
  225. }
  226. .form-textarea{
  227. font-size: 30upx;
  228. color: #999999;
  229. height: 100upx;
  230. padding: 4upx 0;
  231. }
  232. .birth-picker {
  233. flex: 1;
  234. display: flex;
  235. align-items: center;
  236. .right-box{
  237. width: 100%;
  238. display: flex;
  239. align-items: center;
  240. .input-box{
  241. width: 470upx;
  242. }
  243. .arrow{
  244. width: 13upx;
  245. height: 23upx;
  246. margin-left: 20upx;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .btn-box{
  254. height: 120upx;
  255. padding: 0 30upx;
  256. display: flex;
  257. align-items: center;
  258. justify-content: center;
  259. background: #FFFFFF;
  260. .sub-btn{
  261. width: 100%;
  262. height: 88upx;
  263. line-height: 88upx;
  264. text-align: center;
  265. font-size: 30upx;
  266. font-family: PingFang SC;
  267. font-weight: bold;
  268. color: #FFFFFF;
  269. background: #018C39;
  270. border-radius: 44upx;
  271. }
  272. }
  273. }
  274. </style>