index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="客户姓名" prop="userName">
  5. <el-input v-model="queryParams.userName" placeholder="请输入客户姓名" clearable size="small"
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="约诊医生" prop="doctorName">
  9. <el-input v-model="queryParams.doctorName" placeholder="请输入约诊医生" clearable size="small"
  10. @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item label="商品名称" prop="packageName">
  13. <el-input v-model="queryParams.packageName" placeholder="请输入挂载商品名称" clearable size="small"
  14. @keyup.enter.native="handleQuery" />
  15. </el-form-item>
  16. <el-form-item label="订单号" prop="orderCode">
  17. <el-input v-model="queryParams.orderCode" placeholder="请输入订单号" clearable size="small"
  18. @keyup.enter.native="handleQuery" />
  19. </el-form-item>
  20. <el-form-item label="当前进度" prop="currentStep">
  21. <el-select v-model="queryParams.currentStep" placeholder="当前进度" clearable size="small">
  22. <el-option v-for="dict in currentStepOptions" :key="dict.dictValue" :label="dict.dictLabel"
  23. :value="dict.dictValue" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="完成时间" prop="completedTime">
  27. <el-date-picker clearable size="small" v-model="queryParams.completedTime" type="date" value-format="yyyy-MM-dd"
  28. placeholder="选择完成时间">
  29. </el-date-picker>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-table border v-loading="loading" :data="collectionScheduleList" @selection-change="handleSelectionChange">
  37. <el-table-column type="selection" width="55" align="center" />
  38. <el-table-column label="客户姓名" align="center" prop="userName" />
  39. <el-table-column label="约诊医生" align="center" prop="doctorName" />
  40. <el-table-column label="订单号" align="center" prop="orderCode" />
  41. <el-table-column label="挂载商品" align="center" prop="packageName" />
  42. <el-table-column label="当前进度" align="center" prop="currentStep">
  43. <template slot-scope="scope">
  44. <el-tag v-if="scope.row.currentStep != null" :type="stepColorMap[scope.row.currentStep] || 'info'"
  45. size="small">
  46. {{ getStepLabel(scope.row.currentStep) }}
  47. </el-tag>
  48. <span v-else>—</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="创建时间" align="center" width="180">
  52. <template slot-scope="scope">
  53. <span>{{ formatTime(scope.row.createTime) }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="终止时间" align="center" prop="terminatedTime" width="180">
  57. <template slot-scope="scope">
  58. <span>{{ parseTime(scope.row.terminatedTime, '{y}-{m}-{d}') }}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="终止原因" align="center" prop="remark" />
  62. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  63. <template slot-scope="scope">
  64. <el-button v-if="scope.row.currentStep == 5 && scope.row.status == 1" size="mini" type="text"
  65. @click="confirmHandle(scope.row)">确认</el-button>
  66. <el-button size="mini" type="text" icon="el-icon-delete" @click="endProcess(scope.row)"
  67. v-hasPermi="['qw:collectionSchedule:stop']" :disabled="scope.row.status !== 1"
  68. :style="{ color: scope.row.status === 1 ? '#f56c6c' : '#999' }">终止</el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  73. @pagination="getList" />
  74. <!-- 终止原因弹窗 -->
  75. <el-dialog title="终止进度" :visible.sync="endProcessVisible" width="400px" @close="resetEndForm">
  76. <el-form :model="endForm" ref="endFormRef" label-width="80px">
  77. <el-form-item label="终止原因" prop="remark" :rules="[{ required: true, message: '请输入终止原因', trigger: 'blur' }]">
  78. <el-input v-model="endForm.remark" type="textarea" :rows="4" placeholder="请输入终止原因" />
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button @click="endProcessVisible = false">取 消</el-button>
  83. <el-button type="primary" @click="submitEndProcess">确 定</el-button>
  84. </div>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import { listCollectionSchedule, addCollectionSchedule, updateCollectionSchedule, exportCollectionSchedule, getCollectionScheduleSteps, stop, confirm } from "@/api/qw/collectionSchedule";
  90. export default {
  91. name: "CollectionSchedule",
  92. data() {
  93. // 定义状态颜色映射(若依常用色系)
  94. const stepColorMap = {
  95. 1: 'primary', // 待用户第一次确认 —— 蓝色
  96. 2: 'warning', // 待开方 —— 橙色
  97. 3: 'danger', // 待药师审核 —— 红色
  98. 4: 'success', // 待建议 —— 绿色
  99. 5: 'info', // 待用户二次确认 —— 灰蓝
  100. 6: 'success', // 完成 —— 蓝色
  101. 7: 'warning', //待支付
  102. };
  103. return {
  104. // === 新增:终止弹窗相关 ===
  105. endProcessVisible: false,
  106. endForm: {
  107. id: null,
  108. collectionId: null,
  109. remark: '',
  110. orderCode: null
  111. },
  112. // 遮罩层
  113. loading: true,
  114. // 导出遮罩层
  115. exportLoading: false,
  116. // 选中数组
  117. ids: [],
  118. // 非单个禁用
  119. single: true,
  120. // 非多个禁用
  121. multiple: true,
  122. // 显示搜索条件
  123. showSearch: true,
  124. // 总条数
  125. total: 0,
  126. // 用户信息采集进度表格数据
  127. collectionScheduleList: [],
  128. // 弹出层标题
  129. title: "",
  130. // 是否显示弹出层
  131. open: false,
  132. // 当前流程节点字典:(1:待用户第一次确认、2:待开方、3:待药师审核、4:待建议、5:待用户二次确认、6:完成);其中带疗法模式有1,2,3,5,6;无疗法模式只有1,4,5,6
  133. currentStepOptions: [],
  134. // 查询参数
  135. queryParams: {
  136. pageNum: 1,
  137. pageSize: 10,
  138. collectionId: null,
  139. userId: null,
  140. userName: null,
  141. doctorId: null,
  142. doctorName: null,
  143. orderCode: null,
  144. packageId: null,
  145. packageName: null,
  146. currentStep: null,
  147. status: null,
  148. completedTime: null,
  149. terminatedTime: null,
  150. terminatedBy: null,
  151. },
  152. // 表单参数
  153. form: {},
  154. // 表单校验
  155. rules: {
  156. },
  157. stepColorMap, // 暴露给模板使用
  158. };
  159. },
  160. created() {
  161. this.getList();
  162. getCollectionScheduleSteps().then(response => {
  163. this.currentStepOptions = response.data;
  164. });
  165. },
  166. methods: {
  167. /** 查询用户信息采集进度列表 */
  168. getList() {
  169. this.loading = true;
  170. listCollectionSchedule(this.queryParams).then(response => {
  171. this.collectionScheduleList = response.rows;
  172. this.total = response.total;
  173. this.loading = false;
  174. });
  175. },
  176. async confirmHandle(row) {
  177. const param = row;
  178. try {
  179. await this.$confirm('是否帮客户第二次确认?', "提示", {
  180. confirmButtonText: "确定",
  181. cancelButtonText: "取消",
  182. type: "warning"
  183. });
  184. const res = await confirm(param);
  185. if (res && res.code === 200) {
  186. this.getList();// 刷新列表
  187. this.$message.success('确认成功');
  188. } else {
  189. this.$message.error(res.msg);
  190. }
  191. } catch (error) {
  192. }
  193. },
  194. // 取消按钮
  195. cancel() {
  196. this.open = false;
  197. this.reset();
  198. },
  199. // 表单重置
  200. reset() {
  201. this.form = {
  202. id: null,
  203. collectionId: null,
  204. userId: null,
  205. userName: null,
  206. doctorId: null,
  207. doctorName: null,
  208. orderCode: null,
  209. packageId: null,
  210. packageName: null,
  211. currentStep: null,
  212. status: 0,
  213. createTime: null,
  214. completedTime: null,
  215. terminatedTime: null,
  216. terminatedBy: null,
  217. remark: null
  218. };
  219. this.resetForm("form");
  220. },
  221. /** 搜索按钮操作 */
  222. handleQuery() {
  223. this.queryParams.pageNum = 1;
  224. this.getList();
  225. },
  226. /** 重置按钮操作 */
  227. resetQuery() {
  228. this.resetForm("queryForm");
  229. this.handleQuery();
  230. },
  231. /** 终止按钮操作 - 打开弹窗 */
  232. endProcess(row) {
  233. this.endForm.id = row.id;
  234. this.endForm.collectionId = row.collectionId;
  235. this.endForm.remark = '';
  236. this.endForm.orderCode = row.orderCode;
  237. this.endProcessVisible = true;
  238. },
  239. /** 提交终止操作 */
  240. submitEndProcess() {
  241. this.$refs["endFormRef"].validate(valid => {
  242. if (valid) {
  243. const { id, collectionId, remark,orderCode } = this.endForm
  244. this.$confirm('确认终止该采集进度?', '提示', {
  245. confirmButtonText: '确定',
  246. cancelButtonText: '取消',
  247. type: 'warning'
  248. }).then(() => {
  249. stop({ id, collectionId, remark, orderCode }).then(response => {
  250. this.msgSuccess("终止成功");
  251. this.endProcessVisible = false;
  252. this.getList();
  253. }).catch(() => {
  254. // 可选:错误提示
  255. });
  256. }).catch(() => {
  257. // 取消
  258. });
  259. }
  260. });
  261. },
  262. /** 重置终止表单 */
  263. resetEndForm() {
  264. this.$refs["endFormRef"] && this.$refs["endFormRef"].resetFields();
  265. this.endForm.id = null;
  266. this.endForm.collectionId = null;
  267. this.endForm.remark = '';
  268. this.endForm.orderCode = null;
  269. },
  270. // 多选框选中数据
  271. handleSelectionChange(selection) {
  272. this.ids = selection.map(item => item.id)
  273. this.single = selection.length !== 1
  274. this.multiple = !selection.length
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.reset();
  279. this.open = true;
  280. this.title = "添加用户信息采集进度";
  281. },
  282. /** 提交按钮 */
  283. submitForm() {
  284. this.$refs["form"].validate(valid => {
  285. if (valid) {
  286. if (this.form.id != null) {
  287. updateCollectionSchedule(this.form).then(response => {
  288. this.msgSuccess("修改成功");
  289. this.open = false;
  290. this.getList();
  291. });
  292. } else {
  293. addCollectionSchedule(this.form).then(response => {
  294. this.msgSuccess("新增成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. }
  299. }
  300. });
  301. },
  302. /** 导出按钮操作 */
  303. handleExport() {
  304. const queryParams = this.queryParams;
  305. this.$confirm('是否确认导出所有用户信息采集进度数据项?', "警告", {
  306. confirmButtonText: "确定",
  307. cancelButtonText: "取消",
  308. type: "warning"
  309. }).then(() => {
  310. this.exportLoading = true;
  311. return exportCollectionSchedule(queryParams);
  312. }).then(response => {
  313. this.download(response.msg);
  314. this.exportLoading = false;
  315. }).catch(() => { });
  316. },
  317. getStepLabel(currentStep) {
  318. if (currentStep == null) return '—';
  319. const option = this.currentStepOptions.find(opt => opt.dictValue === currentStep);
  320. return option ? option.dictLabel : '未知状态';
  321. },
  322. formatTime(isoString) {
  323. if (!isoString) return '';
  324. const date = new Date(isoString);
  325. // 检查是否有效日期
  326. if (isNaN(date.getTime())) return isoString;
  327. const pad = n => n.toString().padStart(2, '0');
  328. const year = date.getFullYear();
  329. const month = pad(date.getMonth() + 1);
  330. const day = pad(date.getDate());
  331. const hours = pad(date.getHours());
  332. const minutes = pad(date.getMinutes());
  333. const seconds = pad(date.getSeconds());
  334. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  335. }
  336. }
  337. };
  338. </script>