index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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="doctorName">
  5. <el-input
  6. v-model="queryParams.doctorName"
  7. placeholder="请输入医生姓名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="客户" prop="name">
  14. <el-input
  15. v-model="queryParams.name"
  16. placeholder="请输入客户姓名"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="升单类型" prop="type">
  23. <el-select v-model="queryParams.type" placeholder="请选择升单类型" clearable size="small">
  24. <el-option
  25. v-for="dict in typeOptions"
  26. :key="dict.dictValue"
  27. :label="dict.dictLabel"
  28. :value="dict.dictValue"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="处理状态" prop="status">
  33. <el-select v-model="queryParams.status" placeholder="请选择处理状态" clearable size="small">
  34. <el-option
  35. v-for="dict in statusOptions"
  36. :key="dict.dictValue"
  37. :label="dict.dictLabel"
  38. :value="dict.dictValue"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <div class="tab-status-filter mb10">
  48. <el-radio-group v-model="queryParams.status" @change="handleStatusChange" size="small">
  49. <el-radio-button label="">全部</el-radio-button>
  50. <el-radio-button label="0">待处理</el-radio-button>
  51. <el-radio-button label="1">已处理</el-radio-button>
  52. </el-radio-group>
  53. </div>
  54. <el-table border v-loading="loading" :data="companyUserTaskList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center"/>
  56. <el-table-column label="医生" align="center" prop="doctorName"/>
  57. <el-table-column label="客户" align="center" prop="name"/>
  58. <el-table-column label="电话" align="center" prop="phone">
  59. <template slot-scope="scope">
  60. <div style="display: flex; align-items: center; gap: 8px;">
  61. <!-- 显示解密后的电话,或原始加密电话,或占位符 -->
  62. <span class="detail-value">
  63. {{ scope.row._decryptedPhone !== undefined
  64. ? (scope.row._decryptedPhone || '—')
  65. : (scope.row.phone ? '******' : '—') }}
  66. </span>
  67. <!-- 放大镜图标按钮 -->
  68. <el-button
  69. v-if="scope.row.id"
  70. type="text"
  71. icon="el-icon-search"
  72. size="mini"
  73. :loading="scope.row._phoneLoading"
  74. @click="fetchDecryptedPhoneForRow(scope.row)"
  75. title="点击查看真实号码"
  76. style="padding: 0; margin-left: 0;"
  77. ></el-button>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="客户头像" align="center" prop="avatar" width="100px">
  82. <template slot-scope="scope">
  83. <el-popover
  84. placement="right"
  85. title=""
  86. trigger="hover">
  87. <img slot="reference" :src="scope.row.avatar" width="60px">
  88. <img :src="scope.row.avatar" style="max-width: 200px;">
  89. </el-popover>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="升单类型" align="center" prop="type">
  93. <template slot-scope="scope">
  94. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="处理状态" align="center" prop="status">
  98. <template slot-scope="scope">
  99. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  103. <template slot-scope="scope">
  104. <el-button
  105. size="mini"
  106. type="text"
  107. icon="el-icon-user"
  108. @click="handleMemberdetails(scope.row)"
  109. >会员详情
  110. </el-button>
  111. <el-button
  112. size="mini"
  113. type="text"
  114. icon="el-icon-edit"
  115. @click="handleUpdate(scope.row)"
  116. v-if="scope.row.status===0"
  117. v-hasPermi="['qw:companyUserTask:edit']"
  118. >处理
  119. </el-button>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <pagination
  124. v-show="total>0"
  125. :total="total"
  126. :page.sync="queryParams.pageNum"
  127. :limit.sync="queryParams.pageSize"
  128. @pagination="getList"
  129. />
  130. <!-- 会员详情抽屉 -->
  131. <el-drawer
  132. :title="show.title"
  133. :visible.sync="show.open"
  134. direction="rtl"
  135. size="75%"
  136. :before-close="handleCloseDrawer"
  137. append-to-body
  138. >
  139. <userDetails ref="userDetails" @close="handleCloseDrawer" />
  140. </el-drawer>
  141. </div>
  142. </template>
  143. <script>
  144. import {
  145. listCompanyUserTask,
  146. getCompanyUserTask,
  147. getUserPhone,
  148. delCompanyUserTask,
  149. updateCompanyUserTask,
  150. } from "@/api/qw/companyUserTask";
  151. import userDetails from '@/views/store/components/userDetails.vue';
  152. export default {
  153. name: "CompanyUserTask",
  154. components: {
  155. userDetails
  156. },
  157. data() {
  158. return {
  159. // 遮罩层
  160. loading: true,
  161. // 导出遮罩层
  162. exportLoading: false,
  163. // 选中数组
  164. ids: [],
  165. // 非单个禁用
  166. single: true,
  167. // 非多个禁用
  168. multiple: true,
  169. // 显示搜索条件
  170. showSearch: true,
  171. // 总条数
  172. total: 0,
  173. // 销售处理sop任务表格数据
  174. companyUserTaskList: [],
  175. // 弹出层标题
  176. title: "",
  177. // 是否显示弹出层
  178. open: false,
  179. // 处理状态字典
  180. statusOptions: [],
  181. // 会员详情抽屉
  182. show: {
  183. title: "会员详情",
  184. open: false,
  185. },
  186. // 1:未升单未购 2:未升单已购单 3:升单未购 4:升单已购字典
  187. typeOptions: [],
  188. // 查询参数
  189. queryParams: {
  190. pageNum: 1,
  191. pageSize: 10,
  192. orderCode: null,
  193. doctorId: null,
  194. doctorName: null,
  195. userId: null,
  196. name: null,
  197. status: null,
  198. },
  199. // 表单参数
  200. form: {},
  201. // 表单校验
  202. rules: {},
  203. };
  204. },
  205. created() {
  206. this.getList();
  207. this.getDicts("sop_task_status").then(response => {
  208. this.statusOptions = response.data;
  209. });
  210. this.getDicts("upgrade_order_type").then(response => {
  211. this.typeOptions = response.data;
  212. });
  213. },
  214. beforeDestroy() {
  215. // 关闭抽屉
  216. this.show.open = false;
  217. },
  218. methods: {
  219. /** 查询销售处理sop任务列表 */
  220. getList() {
  221. this.loading = true;
  222. listCompanyUserTask(this.queryParams).then(response => {
  223. // 清理每行的临时解密字段(避免旧数据显示)
  224. this.companyUserTaskList = (response.rows || []).map(row => {
  225. const { _decryptedPhone, _phoneLoading, ...cleanRow } = row; // 移除临时字段
  226. return { ...cleanRow };
  227. });
  228. this.total = response.total;
  229. this.loading = false;
  230. });
  231. },
  232. // 取消按钮
  233. cancel() {
  234. this.open = false;
  235. this.reset();
  236. },
  237. // 表单重置
  238. reset() {
  239. this.form = {
  240. id: null,
  241. orderCode: null,
  242. doctorId: null,
  243. userId: null,
  244. status: null,
  245. remark: null
  246. };
  247. this.resetForm("form");
  248. },
  249. /** 搜索按钮操作 */
  250. handleQuery() {
  251. this.queryParams.pageNum = 1;
  252. this.getList();
  253. },
  254. /** 重置按钮操作 */
  255. resetQuery() {
  256. this.resetForm("queryForm");
  257. this.handleQuery();
  258. },
  259. // 多选框选中数据
  260. handleSelectionChange(selection) {
  261. this.ids = selection.map(item => item.id)
  262. this.single = selection.length !== 1
  263. this.multiple = !selection.length
  264. },
  265. /** 会员详情按钮操作 */
  266. handleMemberdetails(row) {
  267. if (!row.userId) {
  268. this.$message.warning("该客户未绑定会员");
  269. return;
  270. }
  271. this.show.title = `会员详情 - ${row.name || '未知客户'}`;
  272. this.show.open = true;
  273. // 确保DOM更新后再调用子组件方法
  274. this.$nextTick(() => {
  275. if (this.$refs.userDetails) {
  276. this.$refs.userDetails.getDetails(row.userId, row);
  277. }
  278. });
  279. },
  280. /** 关闭会员详情抽屉 */
  281. handleCloseDrawer() {
  282. this.show.open = false;
  283. // 重置子组件状态
  284. if (this.$refs.userDetails && this.$refs.userDetails.reset) {
  285. this.$refs.userDetails.reset();
  286. }
  287. },
  288. /** 提交按钮 */
  289. submitForm() {
  290. this.$refs["form"].validate(valid => {
  291. if (valid) {
  292. if (this.form.id != null) {
  293. updateCompanyUserTask(this.form).then(response => {
  294. this.msgSuccess("修改成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. }
  299. }
  300. });
  301. },
  302. /** 处理按钮操作 */
  303. handleUpdate(row) {
  304. const id = row.id;
  305. if (!id) {
  306. this.$message.warning("无效的任务ID");
  307. return;
  308. }
  309. // 1. 先获取任务详情
  310. getCompanyUserTask(id).then(response => {
  311. const taskData = response.data;
  312. this.form = taskData; // 保存表单数据(虽然更新时可能不需要全部字段)
  313. // 2. 弹出确认框
  314. const customerName = taskData.name || '未知客户';
  315. this.$confirm(`确认将客户 “${customerName}” 的任务标记为已处理?`, "确认处理", {
  316. confirmButtonText: "确定",
  317. cancelButtonText: "取消",
  318. type: "warning"
  319. }).then(() => { //箭头函数,this 正确
  320. // 3. 提交更新(只需传 id 和 status)
  321. const submitData = { id: taskData.id,status: 1};
  322. return updateCompanyUserTask(submitData);
  323. }).then(() => {
  324. this.msgSuccess("处理成功");
  325. this.getList(); // 刷新列表
  326. }).catch(() => {
  327. });
  328. }).catch(error => {
  329. console.error("获取任务失败", error);
  330. this.$message.error("获取任务信息失败");
  331. });
  332. },
  333. /** 切换状态Tab */
  334. handleStatusChange() {
  335. this.queryParams.pageNum = 1; // 切换时重置页码
  336. this.getList();
  337. },
  338. /** 获取并显示当前行解密后的电话 */
  339. async fetchDecryptedPhoneForRow(row) {
  340. if (!row.id || row._phoneLoading) return;
  341. // 避免重复请求
  342. this.$set(row, '_phoneLoading', true);
  343. try {
  344. const response = await getUserPhone(row.id);
  345. const phone = response.userPhone || '—';
  346. this.$set(row, '_decryptedPhone', phone);
  347. } catch (error) {
  348. this.$message.error('获取电话失败');
  349. this.$set(row, '_decryptedPhone', '获取失败');
  350. } finally {
  351. this.$set(row, '_phoneLoading', false);
  352. }
  353. },
  354. }
  355. };
  356. </script>
  357. <style scoped>
  358. .mb10 {
  359. margin-bottom: 10px;
  360. }
  361. .tab-status-filter {
  362. margin-bottom: 10px;
  363. }
  364. .detail-value {
  365. font-weight: 500;
  366. color: #606266;
  367. }
  368. /* 抽屉样式优化 */
  369. .el-drawer__header {
  370. margin-bottom: 0;
  371. padding: 15px 20px;
  372. border-bottom: 1px solid #eee;
  373. }
  374. .el-drawer__body {
  375. padding: 15px 20px;
  376. overflow-y: auto;
  377. }
  378. </style>