add.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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">
  69. <view class="form-box-label">选择服务</view>
  70. <view class="form-box-content" @click="selectCate">
  71. <view class="form-box-content-text" v-if="!cate.title">请选择</view>
  72. <view class="form-box-content-text" v-if="cate.title">{{cate.title}}</view>
  73. <image src="../../images/xiangyou-xiao.png"></image>
  74. </view>
  75. </view>
  76. <view class="form-box">
  77. <view class="form-box-label">价格(/人/天)<text class="text-red">*</text></view>
  78. <view class="form-box-content">
  79. <input type="number" placeholder="请填写" v-model="price" />
  80. </view>
  81. </view>
  82. <view class="form-box">
  83. <view class="form-box-label">预收金</view>
  84. <view class="form-box-content">
  85. <input type="number" placeholder="请填写" v-model="pre_money" />
  86. </view>
  87. </view>
  88. <view class="form-box">
  89. <view class="form-box-label">选择护工</view>
  90. <view class="form-box-content" @click="goSelectWorker">
  91. <view class="form-box-content-text" v-if="!unames">请选择</view>
  92. <view class="form-box-content-text" v-if="unames">{{unames}}</view>
  93. <image src="../../images/xiangyou-xiao.png"></image>
  94. </view>
  95. </view>
  96. <view class="form-box form-box2">
  97. <view class="form-box-label">备注</view>
  98. <view class="form-box-textarea">
  99. <textarea style="height:120rpx;" v-model="remark" placeholder="请填写" />
  100. </view>
  101. </view>
  102. <view class="book-btn" @click="saveBtn()">提交</view>
  103. </view>
  104. <cpicker v-if="genders.length > 0" :list="genders" :show.sync="genderShow" :did="gender.id" @confirm="selectedGenderVal"></cpicker>
  105. <cpicker v-if="deps.length > 0" :list="deps" :show.sync="depShow" :did="dep.id" @confirm="selectedDepVal"></cpicker>
  106. <cpicker v-if="cates.length > 0" :list="cates" :show.sync="cateShow" :did="cate.id" @confirm="selectedCateVal"></cpicker>
  107. <w-picker
  108. :visible.sync="startVisible"
  109. mode="date"
  110. startYear="2021"
  111. endYear="5000"
  112. themeColor="#FF7576"
  113. :value="start"
  114. :current="true"
  115. fields="minute"
  116. @confirm="onConfirm($event,'date')"
  117. :disabled-after="false"
  118. ref="date"
  119. ></w-picker>
  120. </view>
  121. </template>
  122. <script>
  123. var app = getApp();
  124. import cpicker from "../../components/cpicker/cpicker.vue";
  125. import wpicker from "../../components/w-picker/w-picker.vue";
  126. export default {
  127. components: {
  128. cpicker,
  129. wpicker
  130. },
  131. data() {
  132. return {
  133. flag: false,
  134. start:'',
  135. startVisible:false,
  136. contact: '',
  137. name: '',
  138. phone: '',
  139. ill: '',
  140. age: '',
  141. bed: '',
  142. gender: {
  143. id: 1,
  144. title: '男'
  145. },
  146. genderShow: false,
  147. genders:[{"id":1,"title":"男"},{"id":2,"title":"女"}],
  148. dep: {
  149. id: 0,
  150. title: ''
  151. },
  152. depShow: false,
  153. deps:[],
  154. cate: {
  155. id: 0,
  156. title: '',
  157. price: 0,
  158. },
  159. cateShow: false,
  160. cates:[],
  161. remark: '',
  162. price: '',
  163. unames: '',
  164. workers: [],
  165. pre_money: '',
  166. }
  167. },
  168. onLoad(option) {
  169. },
  170. onShow() {
  171. var that = this;
  172. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  173. var apiname = res.data.apiname;
  174. console.log(res);
  175. if(apiname == 'dep'){
  176. that.deps = res.data.data;
  177. }else if(apiname == 'cate'){
  178. that.cates = res.data.data;
  179. } else if(apiname == 'order'){
  180. uni.navigateTo({
  181. url: '/pages/order/index'
  182. });
  183. }
  184. }
  185. this.getDep();
  186. this.getCate();
  187. },
  188. methods: {
  189. getUrlCode (name) {
  190. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  191. },
  192. selectGender(){
  193. this.genderShow = true;
  194. },
  195. selectedGenderVal(obj){
  196. console.log(obj)
  197. this.gender = obj;
  198. },
  199. selectDep(){
  200. this.depShow = true;
  201. },
  202. selectedDepVal(obj){
  203. console.log(obj)
  204. this.dep = obj;
  205. },
  206. getDep(){
  207. app.ajax({
  208. url: app.globalData.serverUrl + 'common/dep',
  209. type: 'POST',
  210. apiname: 'dep',
  211. });
  212. },
  213. selectCate(){
  214. this.cateShow = true;
  215. },
  216. selectedCateVal(obj){
  217. console.log(obj)
  218. this.cate = obj;
  219. this.price = obj.price;
  220. },
  221. getCate(){
  222. app.ajax({
  223. url: app.globalData.serverUrl + 'cate/cateList',
  224. type: 'POST',
  225. apiname: 'cate',
  226. });
  227. },
  228. onConfirm(e,type){
  229. this.start = e.result;
  230. },
  231. selectStart(){
  232. this.startVisible = true;
  233. },
  234. goSelectWorker(){
  235. var that = this;
  236. uni.navigateTo({
  237. url: '/pages/order/worker',
  238. events: {
  239. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  240. acceptDataFromOpenedPage: function(data) {
  241. console.log('jieshou:',data)
  242. that.workers = data;
  243. let names = [];
  244. that.workers.forEach((item,index) => {
  245. if(index < 2){
  246. names.push(item.name)
  247. }
  248. });
  249. if(that.workers.length > 2){
  250. that.unames = names.join(',') + '...';
  251. }else{
  252. that.unames = names.join(',');
  253. }
  254. }
  255. },
  256. success: function(res) {
  257. // 通过eventChannel向被打开页面传送数据
  258. res.eventChannel.emit('acceptDataFromOpenerPage', { workers: that.workers })
  259. }
  260. })
  261. },
  262. saveBtn(){
  263. if(!this.contact){
  264. uni.showToast({
  265. title: '请输入联系人',
  266. icon: 'none',
  267. duration: 2000
  268. })
  269. return;
  270. }
  271. if(!this.phone){
  272. uni.showToast({
  273. title: '请输入手机号',
  274. icon: 'none',
  275. duration: 2000
  276. })
  277. return;
  278. }
  279. if(!this.name){
  280. uni.showToast({
  281. title: '请输入姓名',
  282. icon: 'none',
  283. duration: 2000
  284. })
  285. return;
  286. }
  287. if(!this.age){
  288. uni.showToast({
  289. title: '请输入年龄',
  290. icon: 'none',
  291. duration: 2000
  292. })
  293. return;
  294. }
  295. if(!this.bed){
  296. uni.showToast({
  297. title: '请输入床号',
  298. icon: 'none',
  299. duration: 2000
  300. })
  301. return;
  302. }
  303. if(!this.ill){
  304. uni.showToast({
  305. title: '请输入所患疾病',
  306. icon: 'none',
  307. duration: 2000
  308. })
  309. return;
  310. }
  311. if(!this.start){
  312. uni.showToast({
  313. title: '请选择预约时间',
  314. icon: 'none',
  315. duration: 2000
  316. })
  317. return;
  318. }
  319. let param = {
  320. contact: this.contact,
  321. phone: this.phone,
  322. name: this.name,
  323. gender: this.gender.id,
  324. age: this.age,
  325. bed: this.bed,
  326. ill: this.ill,
  327. start: this.start,
  328. remark: this.remark,
  329. dep_id: this.dep.id,
  330. }
  331. app.ajax({
  332. url: app.globalData.serverUrl + 'Worker/order',
  333. type: 'POST',
  334. apiname: 'order',
  335. data: param
  336. });
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss" scoped>
  342. .navbg{
  343. width: 100%;
  344. height: 300rpx;
  345. }
  346. .book-main{
  347. width: 710rpx;
  348. // position: absolute;
  349. // z-index: 10;
  350. // top: 300rpx;
  351. // left: 0;
  352. // bottom: 0;
  353. overflow: auto;
  354. }
  355. .book-btn{
  356. width: 710rpx;
  357. height: 90rpx;
  358. line-height: 90rpx;
  359. background-color: var(--themeColor);
  360. color: #ffffff;
  361. font-size: 34rpx;
  362. font-weight: bold;
  363. text-align: center;
  364. border-radius: 10rpx;
  365. }
  366. </style>