add.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view>
  3. <view class="container book-main">
  4. <view class="form-box">
  5. <view class="form-box-label">选择科室</view>
  6. <view class="form-box-content" @click="selectDep">
  7. <view class="form-box-content-text" v-if="!dep.title">请选择</view>
  8. <view class="form-box-content-text" v-if="dep.title">{{dep.title}}</view>
  9. <image src="../../images/xiangyou-xiao.png"></image>
  10. </view>
  11. </view>
  12. <view class="form-box">
  13. <view class="form-box-label">联系人 <text class="text-red">*</text></view>
  14. <view class="form-box-content">
  15. <input type="text" v-model="contact" placeholder="请填写" />
  16. </view>
  17. </view>
  18. <view class="form-box">
  19. <view class="form-box-label">联系手机号 <text class="text-red">*</text></view>
  20. <view class="form-box-content">
  21. <input type="tel" v-model="phone" placeholder="请填写" />
  22. </view>
  23. </view>
  24. <view class="form-box form-box2">
  25. <view class="form-box-label">被陪护人信息</view>
  26. <view class="form-box-sub">
  27. <view class="form-box-label">姓名<text class="text-red">*</text></view>
  28. <view class="form-box-content">
  29. <input type="text" placeholder="请填写" v-model="name" />
  30. </view>
  31. </view>
  32. <view class="form-box-sub">
  33. <view class="form-box-label">性别<text class="text-red">*</text></view>
  34. <view class="form-box-content" @click="selectGender">
  35. <view class="form-box-content-text">{{gender.title}}</view>
  36. <image src="../../images/xiangyou-xiao.png"></image>
  37. </view>
  38. </view>
  39. <view class="form-box-sub">
  40. <view class="form-box-label">年龄<text class="text-red">*</text></view>
  41. <view class="form-box-content">
  42. <input type="number" placeholder="请填写" v-model="age" />
  43. </view>
  44. </view>
  45. <view class="form-box-sub">
  46. <view class="form-box-label">床号<text class="text-red">*</text></view>
  47. <view class="form-box-content">
  48. <input type="text" placeholder="请填写" v-model="bed" />
  49. </view>
  50. </view>
  51. <view class="form-box-sub">
  52. <view class="form-box-label">所患疾病<text class="text-red">*</text></view>
  53. <view class="form-box-content">
  54. <input type="text" placeholder="请填写" v-model="ill" />
  55. </view>
  56. </view>
  57. </view>
  58. <view class="form-box">
  59. <view class="form-box-label">预约时间<text class="text-red">*</text></view>
  60. <view class="form-box-content">
  61. <view class="form-box-content" @click="selectStart">
  62. <view class="form-box-content-text" v-if="!start">请选择</view>
  63. <view class="form-box-content-text" v-if="start">{{start}}</view>
  64. <image src="../../images/xiangyou-xiao.png"></image>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="form-box form-box2">
  69. <view class="form-box-label">备注</view>
  70. <view class="form-box-textarea">
  71. <textarea style="height:120rpx;" v-model="remark" placeholder="请填写" />
  72. </view>
  73. </view>
  74. <view class="book-btn" @click="saveBtn()">提交</view>
  75. </view>
  76. <cpicker v-if="genders.length > 0" :list="genders" :show.sync="genderShow" :did="gender.id" @confirm="selectedGenderVal"></cpicker>
  77. <cpicker v-if="deps.length > 0" :list="deps" :show.sync="depShow" :did="dep.id" @confirm="selectedDepVal"></cpicker>
  78. <w-picker
  79. :visible.sync="startVisible"
  80. mode="date"
  81. startYear="2021"
  82. endYear="5000"
  83. themeColor="#089875"
  84. :value="start"
  85. :current="true"
  86. fields="minute"
  87. @confirm="onConfirm($event,'date')"
  88. :disabled-after="false"
  89. ref="date"
  90. ></w-picker>
  91. </view>
  92. </template>
  93. <script>
  94. var app = getApp();
  95. import cpicker from "../../components/cpicker/cpicker.vue";
  96. import wpicker from "../../components/w-picker/w-picker.vue";
  97. export default {
  98. components: {
  99. cpicker,
  100. wpicker
  101. },
  102. data() {
  103. return {
  104. flag: false,
  105. start:'',
  106. startVisible:false,
  107. contact: '',
  108. name: '',
  109. phone: '',
  110. ill: '',
  111. age: '',
  112. bed: '',
  113. gender: {
  114. id: 1,
  115. title: '男'
  116. },
  117. genderShow: false,
  118. genders:[{"id":1,"title":"男"},{"id":2,"title":"女"}],
  119. dep: {
  120. id: 0,
  121. title: ''
  122. },
  123. depShow: false,
  124. deps:[],
  125. remark: ''
  126. }
  127. },
  128. onLoad(option) {
  129. var orgId = this.getUrlCode('orgId');
  130. if(orgId){
  131. uni.setStorageSync(app.globalData.storagePre+'orgId',orgId);
  132. app.globalData.userinfo.orgId = orgId;
  133. }else{
  134. orgId = uni.getStorageSync(app.globalData.storagePre+'orgId');
  135. if(orgId){
  136. app.globalData.userinfo.orgId = orgId;
  137. }else{
  138. uni.showToast({
  139. title: '参数错误',
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. }
  144. }
  145. },
  146. onShow() {
  147. var that = this;
  148. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  149. var apiname = res.data.apiname;
  150. console.log(res);
  151. if(apiname == 'dep'){
  152. that.deps = res.data.data;
  153. } else if(apiname == 'order'){
  154. uni.navigateTo({
  155. url: '/pages/index/success'
  156. });
  157. }
  158. }
  159. this.getDep();
  160. },
  161. methods: {
  162. getUrlCode (name) {
  163. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  164. },
  165. selectGender(){
  166. this.genderShow = true;
  167. },
  168. selectedGenderVal(obj){
  169. console.log(obj)
  170. this.gender = obj;
  171. },
  172. selectDep(){
  173. this.depShow = true;
  174. },
  175. selectedDepVal(obj){
  176. console.log(obj)
  177. this.dep = obj;
  178. },
  179. getDep(){
  180. app.ajax({
  181. url: app.globalData.serverUrl + 'common/dep',
  182. type: 'POST',
  183. apiname: 'dep',
  184. });
  185. },
  186. onConfirm(e,type){
  187. this.start = e.result;
  188. },
  189. selectStart(){
  190. this.startVisible = true;
  191. },
  192. saveBtn(){
  193. if(!this.contact){
  194. uni.showToast({
  195. title: '请输入联系人',
  196. icon: 'none',
  197. duration: 2000
  198. })
  199. return;
  200. }
  201. if(!this.phone){
  202. uni.showToast({
  203. title: '请输入手机号',
  204. icon: 'none',
  205. duration: 2000
  206. })
  207. return;
  208. }
  209. if(!this.name){
  210. uni.showToast({
  211. title: '请输入姓名',
  212. icon: 'none',
  213. duration: 2000
  214. })
  215. return;
  216. }
  217. if(!this.age){
  218. uni.showToast({
  219. title: '请输入年龄',
  220. icon: 'none',
  221. duration: 2000
  222. })
  223. return;
  224. }
  225. if(!this.bed){
  226. uni.showToast({
  227. title: '请输入床号',
  228. icon: 'none',
  229. duration: 2000
  230. })
  231. return;
  232. }
  233. if(!this.ill){
  234. uni.showToast({
  235. title: '请输入所患疾病',
  236. icon: 'none',
  237. duration: 2000
  238. })
  239. return;
  240. }
  241. if(!this.start){
  242. uni.showToast({
  243. title: '请选择预约时间',
  244. icon: 'none',
  245. duration: 2000
  246. })
  247. return;
  248. }
  249. let param = {
  250. contact: this.contact,
  251. phone: this.phone,
  252. name: this.name,
  253. gender: this.gender.id,
  254. age: this.age,
  255. bed: this.bed,
  256. ill: this.ill,
  257. start: this.start,
  258. remark: this.remark,
  259. depId: this.dep.id
  260. }
  261. app.ajax({
  262. url: app.globalData.serverUrl + 'worker/order',
  263. type: 'POST',
  264. apiname: 'order',
  265. data: param
  266. });
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. .navbg{
  273. width: 100%;
  274. height: 300rpx;
  275. }
  276. .book-main{
  277. width: 710rpx;
  278. // position: absolute;
  279. // z-index: 10;
  280. // top: 300rpx;
  281. // left: 0;
  282. // bottom: 0;
  283. // overflow: auto;
  284. overflow-y: auto;
  285. overflow-x: hidden;
  286. }
  287. .book-btn{
  288. width: 710rpx;
  289. height: 90rpx;
  290. line-height: 90rpx;
  291. background-color: var(--themeColor);
  292. color: #ffffff;
  293. font-size: 34rpx;
  294. font-weight: bold;
  295. text-align: center;
  296. border-radius: 10rpx;
  297. }
  298. </style>