appointment.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="appointment-page" v-loading="loading" element-loading-text="加载中" element-loading-spinner="el-icon-loading">
  3. <el-row>
  4. <el-col :span="24" class="padding20">
  5. <el-form :inline="true" :model="searchForm" class="flex-form" size="small">
  6. <el-form-item label="联系人姓名">
  7. <el-input v-model="searchForm.name" placeholder="请输入姓名(不是昵称)"></el-input>
  8. </el-form-item>
  9. <el-form-item label="预约申请时间">
  10. <el-date-picker
  11. v-model="appointmentTime"
  12. type="daterange"
  13. value-format="yyyy-MM-dd HH:mm:ss"
  14. range-separator="至"
  15. start-placeholder="开始日期"
  16. end-placeholder="结束日期">
  17. </el-date-picker>
  18. </el-form-item>
  19. <el-form-item label="状态">
  20. <!-- 状态 状态 【1.申请预约 2.撤销预约 3.业务人员撤销预约 4.预约报道成功 5.预约超时 】 -->
  21. <el-select v-model="searchForm.status" placeholder="请选择">
  22. <el-option label="请选择" value=""></el-option>
  23. <el-option label="申请预约" value="1"></el-option>
  24. <el-option label="撤销预约" value="2"></el-option>
  25. <el-option label="业务人员撤销预约" value="3"></el-option>
  26. <el-option label="预约报道成功" value="4"></el-option>
  27. <el-option label="预约超时" value="5"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="省/市/区">
  31. <el-cascader style="width:230px;"
  32. :options="options"
  33. :props="{ checkStrictly: true }"
  34. v-model="selectedOptions"
  35. @change="handleChange">
  36. </el-cascader>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="primary" @click="handleQuery">查询</el-button>
  40. <el-button @click="handleReset">重置</el-button>
  41. </el-form-item>
  42. </el-form>
  43. </el-col>
  44. </el-row>
  45. <el-row>
  46. <el-col :span="24" class="padding20 no-padding-top">
  47. <el-table :data="tableData" border stripe style="width: 100%" size="small" max-height="700">
  48. <el-table-column type="index" align="center" label="序号"></el-table-column>
  49. <el-table-column prop="appointmentId" label="预约记录ID" align="center"></el-table-column>
  50. <el-table-column prop="contactName" label="联系人名称" align="center"></el-table-column>
  51. <el-table-column prop="contactPhone" label="联系方式" align="center"></el-table-column>
  52. <el-table-column prop="nickname" label="预约用户昵称" align="center"></el-table-column>
  53. <el-table-column prop="appointmentTime" label="预约时间" align="center"></el-table-column>
  54. <el-table-column prop="appointmentDuration" label="时间区间段" align="center"></el-table-column>
  55. <el-table-column label="状态" align="center">
  56. <template slot-scope="scope">
  57. <!-- 状态 状态 【1.申请预约 2.撤销预约 3.业务人员撤销预约 4.预约报道成功 5.预约超时 】 -->
  58. <span v-if="scope.row.status == 1">申请预约</span>
  59. <span v-if="scope.row.status == 2">撤销预约</span>
  60. <span v-if="scope.row.status == 3">业务人员撤销预约</span>
  61. <span v-if="scope.row.status == 4">预约报道成功</span>
  62. <span v-if="scope.row.status == 5">预约超时</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="addTime" label="预约申请时间" align="center"></el-table-column>
  66. <el-table-column prop="" label="操作" align="center">
  67. <template slot-scope="scope">
  68. <el-button type="text" :disabled="scope.row.status !== 1" @click="handleCancelAppoint(scope.row)">取消预约</el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </el-col>
  73. </el-row>
  74. <el-row>
  75. <el-col :span="24" class="padding20 flexend" >
  76. <el-pagination
  77. @current-change="handleCurrentChange"
  78. :current-page="currentPage"
  79. :page-size="pageSize"
  80. layout="total, prev, pager, next"
  81. :total="total"
  82. size="small"
  83. >
  84. </el-pagination>
  85. </el-col>
  86. </el-row>
  87. </div>
  88. </template>
  89. <script>
  90. import { getAppointmentList, cancelAppointment } from '@/request/request'
  91. import { regionData, CodeToText } from 'element-china-area-data'
  92. export default {
  93. name: 'appointment',
  94. data() {
  95. return {
  96. loading: false,
  97. appointmentTime: '',
  98. searchForm: {
  99. name: '',
  100. start: '',
  101. end: '',
  102. status: '',
  103. province: '浙江省',
  104. city: '杭州市',
  105. county: '上城区'
  106. },
  107. tableData: [],
  108. currentPage: 1,
  109. pageSize: 20,
  110. total: 0,
  111. options: regionData,
  112. selectedOptions: ['330000', '330100', '330102']
  113. };
  114. },
  115. mounted() {
  116. this.handleQuery()
  117. },
  118. methods: {
  119. handleReset () {
  120. this.selectedOptions = ['330000', '330100', '330102']
  121. this.searchForm.province = CodeToText['330000']
  122. this.searchForm.city = CodeToText['330100']
  123. this.searchForm.county = CodeToText['330102']
  124. this.searchForm.status = ''
  125. this.appointmentTime = ''
  126. this.searchForm.name = ''
  127. },
  128. handleQuery () {
  129. if (this.appointmentTime) {
  130. this.searchForm.start = this.appointmentTime[0]
  131. this.searchForm.end = this.appointmentTime[1]
  132. } else {
  133. this.searchForm.start = ''
  134. this.searchForm.end = ''
  135. }
  136. this.currentPage = 1
  137. this.getAppointmentListFn()
  138. },
  139. getAppointmentListFn () {
  140. let data = {
  141. currentPage: this.currentPage,
  142. ...this.searchForm
  143. }
  144. this.loading = true
  145. getAppointmentList(data).then(res => {
  146. this.loading = false
  147. this.total = res.data.total
  148. this.pageSize = res.data.pageSize
  149. this.tableData = res.data.vos || []
  150. }).catch(e => {
  151. this.loading = false
  152. console.log(e);
  153. })
  154. },
  155. handleCurrentChange (currentPage) {
  156. this.currentPage = currentPage
  157. this.getAppointmentListFn()
  158. },
  159. handleCancelAppoint (row) {
  160. this.$confirm('确定取消预约吗?').then( _=> {
  161. this.cancelAppointmentFn(row.appointmentId)
  162. }).catch(_ => {});
  163. },
  164. cancelAppointmentFn (appointmentId) {
  165. let data = {
  166. appointmentId: appointmentId
  167. }
  168. this.loading = true
  169. cancelAppointment(data).then(res => {
  170. this.loading = false
  171. this.$message({
  172. message: '取消成功',
  173. type: 'success'
  174. })
  175. this.getAppointmentListFn()
  176. }).catch(e => {
  177. this.loading = false
  178. console.log(e);
  179. })
  180. },
  181. handleChange (value) {
  182. this.searchForm.province = CodeToText[value[0]]
  183. this.searchForm.city = CodeToText[value[1]]
  184. this.searchForm.county = CodeToText[value[2]]
  185. }
  186. }
  187. };
  188. </script>
  189. <style scoped lang="scss">
  190. .appointment-page {
  191. width: 100%;
  192. height: 100%;
  193. .padding20 {
  194. padding: 20px;
  195. }
  196. .no-padding-top {
  197. padding-top: 0;
  198. }
  199. .flexend {
  200. display: flex;
  201. justify-content: flex-end;
  202. }
  203. }
  204. </style>