addSop.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <div class="app-container">
  3. <div v-if="opType == 0" style="margin: 30px;"> 添加自动化任务</div>
  4. <div v-else-if="opType == 1" style="margin: 30px;"> 修改自动化任务</div>
  5. <div v-else style="margin: 30px;"> 查看自动化任务</div>
  6. <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 30px;">
  7. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  8. <el-form-item label="规则名称" prop="name">
  9. <el-input v-model="form.name" placeholder="请输入规则名称" />
  10. </el-form-item>
  11. <el-form-item label="状态" prop="status">
  12. <dict-tag :options="statusOptions" :value="form.status"></dict-tag>
  13. </el-form-item>
  14. <el-form-item label="筛选方式" prop="filterMode">
  15. <el-radio-group v-model="form.filterMode">
  16. <el-radio :label="1">标签
  17. </el-radio>
  18. <el-radio :label="2" v-show="false">群聊
  19. </el-radio>
  20. </el-radio-group>
  21. <div style="color: #999;font-size: 14px;display: flex;align-items: center;" v-if="form.filterMode == 1">
  22. <i class="el-icon-info"></i>
  23. 标签:根据客户的标签筛选客户进入自动化
  24. </div>
  25. <div style="color: #999;font-size: 14px;display: flex;align-items: center;" v-if="form.filterMode == 2">
  26. <i class="el-icon-info"></i>
  27. 群聊:选择用户所属的群聊,并且只能选择科普模板,科普模板里面第一条规则是发送到群聊,其他规则提醒会发送到群里面的个人
  28. </div>
  29. </el-form-item>
  30. <el-form-item label="次要节点天数" prop="minConversionDay" v-if="/*form.type != 3 && */form.filterMode == 1">
  31. <!-- <el-input-number v-model="form.minConversionDay" :min="1" :max="100"></el-input-number> -->
  32. <el-input style="width: 220px;" v-model="form.minConversionDay" placeholder="请输入次要节点天数" />
  33. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  34. <i class="el-icon-info"></i>
  35. 第一次提醒客服,去联系客户,在【提醒看板】处显示,哪些需要联系的客户,多个使用英文逗号隔开
  36. </div>
  37. </el-form-item>
  38. <el-form-item label="重要节点天数" prop="maxConversionDay" v-if="/*form.type != 3 && */form.filterMode == 1">
  39. <el-input style="width: 220px;" v-model="form.maxConversionDay" placeholder="请输入重要节点天数" />
  40. <!-- <el-input-number v-model="form.maxConversionDay" :min="1" :max="100"></el-input-number> -->
  41. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  42. <i class="el-icon-info"></i>
  43. 第二次提醒客服,去联系客户,在【提醒看板】处显示,哪些需要联系的客户,多个使用英文逗号隔开
  44. </div>
  45. </el-form-item>
  46. <div v-if="form.filterMode == 1">
  47. <el-form-item label="推送方式 ">
  48. <el-radio-group v-model="form.sendType" @input="handleSendTypeChange">
  49. <el-radio v-for="dict in sopSendTypeOptions" :key="dict.dictValue"
  50. :label="parseInt(dict.dictValue)">{{ dict.dictLabel }}</el-radio>
  51. </el-radio-group>
  52. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  53. <i class="el-icon-info"></i>
  54. 群发助手 则是正常的自动化任务,新客对话 是客户进线当天,根据【新客对话模板】的内容,给客户发送相应的消息
  55. </div>
  56. </el-form-item>
  57. <el-form-item label="选择客服" prop="appCustomerId" style="margin-top: 2%">
  58. <div>
  59. <el-button size="medium" icon="el-icon-circle-plus-outline" plain
  60. @click="openSelectCustomerPage(form.type, form.sendType)">请选择客服</el-button>
  61. </div>
  62. <div>
  63. <el-tag style="margin-left: 5px" size="medium" :key="s.id" v-for="s in selected" closable
  64. :disable-transitions="false" @close="handleCloseCustomer(s)">
  65. <span>{{ s.roleName }}</span>
  66. </el-tag>
  67. </div>
  68. </el-form-item>
  69. <el-form-item label="标签规则" prop="filterType">
  70. <el-radio-group v-model="form.filterType">
  71. <el-radio :label="1">含全部标签</el-radio>
  72. <el-radio :label="2">含任意标签</el-radio>
  73. </el-radio-group>
  74. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  75. <i class="el-icon-info"></i>
  76. 【含全部标签】:客户要完全一对一匹配上选择标签,ps:多一个少一个都不行
  77. 【含任意标签】:客户只要有一个标签匹配上即可
  78. </div>
  79. </el-form-item>
  80. <el-form-item label="选择的标签" prop="tags">
  81. <div @click="hangleChangeTags()"
  82. style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 390px">
  83. <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
  84. <el-tag type="success" closable :disable-transitions="false"
  85. v-for="list in selectTagDialog.selected" :key="list.id" @close="handleCloseTags(list)"
  86. style="margin: 3px;">{{ list.name }}
  87. </el-tag>
  88. </div>
  89. </div>
  90. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  91. <i class="el-icon-info"></i>
  92. 选择创建的自动化任务的标签
  93. </div>
  94. </el-form-item>
  95. </div>
  96. <el-form-item label="开始时间" prop="startTime">
  97. <el-date-picker clearable size="small" v-model="form.startTime" type="date" value-format="yyyy-MM-dd"
  98. placeholder="选择开始时间" @change="clearAutoDatesIfNeeded">
  99. </el-date-picker>
  100. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  101. <i class="el-icon-info"></i>
  102. 任务的开始时间,客户进线在开始时间之前就符合此自动化任务的,都会进入到开始时间的营期里
  103. </div>
  104. </el-form-item>
  105. <el-form-item label="任务过期时间" prop="expiryTime">
  106. <el-row>
  107. <el-input-number v-model="form.expiryTime" :min="3" :max="100"></el-input-number>
  108. (小时)
  109. </el-row>
  110. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  111. <i class="el-icon-info"></i>
  112. 发送自动化任务消息的过期时间,超过这个时间,消息将不再发送(作废),比如:9点的消息,设置3个小时过期,12点之后还未发送 则这条消息将过期且不再发送
  113. </div>
  114. </el-form-item>
  115. <el-form-item v-if="form.sendType == 2 && form.sendType != 4 && form.type != 3 && form.filterMode == 1"
  116. label="自动添加自动化" prop="autoSopTime.autoSopType">
  117. <el-radio-group v-model="form.autoSopTime.autoSopType">
  118. <el-radio :label="Number(dict.dictValue)" v-for="dict in autoSopTypeOptions">{{ dict.dictLabel }}</el-radio>
  119. </el-radio-group>
  120. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  121. <i class="el-icon-info"></i>
  122. 这个选项仅作用于【新客户】进线时或【给客户打标签时】,是进入当日的营期 还是 次日的营期或者分营期
  123. </div>
  124. </el-form-item>
  125. <div style="display: flex; align-items: center; flex-wrap: nowrap;">
  126. <div v-if="form.autoSopTime.autoSopType == 1 && form.filterMode == 1"
  127. style="display: flex; align-items: center">
  128. <el-form-item label="起始时间" prop="autoStartTime" label-width="100px"
  129. style="margin: 2% 0;align-items: center;">
  130. <el-time-select style="width: 120px;" placeholder="起始时间" v-model="form.autoSopTime.autoStartTime"
  131. :picker-options="{
  132. start: '00:00',
  133. step: '00:15',
  134. end: '24:00'
  135. }">
  136. </el-time-select>
  137. </el-form-item>
  138. <el-form-item label="结束时间" prop="autoEndTime" label-width="100px"
  139. style="margin: 2% 0; align-items: center; ">
  140. <el-time-select style="width: 120px;" placeholder="结束时间" v-model="form.autoSopTime.autoEndTime"
  141. :picker-options="{
  142. start: '00:00',
  143. step: '00:15',
  144. end: '24:00',
  145. minTime: form.autoSopTime.autoEndTime
  146. }">
  147. </el-time-select>
  148. </el-form-item>
  149. </div>
  150. </div>
  151. <el-form-item v-if="form.autoSopTime.autoSopType == 1" label="过期消息是否发送" prop="autoSopSend" label-width="130px">
  152. <el-radio-group v-model="form.autoSopTime.autoSopSend">
  153. <el-radio :label="1">是</el-radio>
  154. <el-radio :label="2">否</el-radio>
  155. </el-radio-group>
  156. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  157. <i class="el-icon-info"></i>
  158. 起始时间-结束时间之内的进线客户,进入【当日营期】,时间之外的,进入【次日营期】
  159. </div>
  160. </el-form-item>
  161. <div style="display: flex; align-items: center; flex-wrap: nowrap;"
  162. v-if="form.autoSopTime.autoSopType == 3 || form.autoSopTime.autoSopType == 4">
  163. <el-form-item label="选择一个或多个日期" prop="autoDateTime" label-width="150px">
  164. <el-date-picker size="large" type="dates" style="width: 600px" v-model="form.autoSopTime.autoDateTime"
  165. value-format="yyyy-MM-dd" placeholder="选择一个或多个日期【ps:请先选择开始时间,不得小于任务开始时间】"
  166. @change="sortSelectedDates(form.autoSopTime.autoDateTime)" :disabled="!form.startTime">
  167. </el-date-picker>
  168. </el-form-item>
  169. </div>
  170. <el-form-item label="模板" prop="tempId">
  171. <div @click="selectListSopTemp(form.sendType)"
  172. style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;">
  173. <el-tag v-if="form.tempId" type="success" style="margin: 3px;">
  174. {{ form.tempName }}
  175. </el-tag>
  176. <span v-else style="margin: 3px; color: #999;">请点我选择模板</span>
  177. </div>
  178. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  179. <i class="el-icon-info"></i>
  180. 在左边的菜单【任务模板】板块设置好每天要发送的内容
  181. </div>
  182. </el-form-item>
  183. <el-alert v-if="form.autoSopTime.autoSopType == 3" type="warning" :closable="false" show-icon>
  184. <template #title>
  185. <span style="font-size: 23px; line-height: 1.5;">
  186. 此功能用于正课区分营期,可以选择你想要开始营期的具体时间,选择后在此期间添加的用户将会自动进入对应营期。
  187. 例如今天1月1日,选择时间是1月1日,1月5日,1月10日。
  188. 用户1月1日-1月4日添加(添加上对应标签)则会进入1月5日的营期,1月5日-1月9日添加则会进入1月10日营期,1月5日自动给用户发送第一节科普
  189. </span>
  190. </template>
  191. </el-alert>
  192. <el-alert v-if="form.autoSopTime.autoSopType == 4" title="" type="warning" :closable="false" show-icon>
  193. <template #title>
  194. <span style="font-size: 23px; line-height: 1.5;">
  195. 此功能用于先导课区分营期,可以选择先导课开始营期的具体时间,选择后在此期间添加的用户将会自动进入对应营期。
  196. 例如今天1月1日,选择时间是1月1日,1月5日,1月10日。
  197. 用户1月1日-1月4日添加(添加上对应标签)则会进入1月1日的营期,1月5日-1月9日添加则会进入1月5日营期,自动给用户匹配上对应应该听到天数的时间节点
  198. </span>
  199. </template>
  200. </el-alert>
  201. </el-form>
  202. <div slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end;">
  203. <el-button type="primary" v-if="opType != 2" @click="submitForm">确 定</el-button>
  204. <el-button v-if="opType != 2" @click="cancel">取 消</el-button>
  205. </div>
  206. <!-- 选择app客服角色 -->
  207. <el-dialog :title="customerConfig.title" :visible.sync="customerConfig.visible" width="1300px" append-to-body>
  208. <CusRoleList
  209. ref="QwUserList"
  210. :selected="selected"
  211. @confirm="customerSelectedConfirmCallForBind"
  212. @selectionChange="customerSelectionChangeCallForBind"
  213. />
  214. </el-dialog>
  215. <!-- 选择模板 -->
  216. <el-dialog title="选择模板" :visible.sync="tempOpen" append-to-body>
  217. <sop-temp ref="SopTempComments" @sopTemp="sopTemp"></sop-temp>
  218. </el-dialog>
  219. <!-- 标签 -->
  220. <el-dialog title="选择标签"
  221. :visible.sync="selectTagDialog.visible"
  222. width="1000px"
  223. append-to-body
  224. >
  225. <select-tag
  226. :tagSelected="selectTagDialog.selected"
  227. @tagSubmit="tagSubmitForBind"
  228. @tagCancel="tagCancelForBind"
  229. @tagSelection="tagSelectionChangeCallForBind"
  230. />
  231. </el-dialog>
  232. </div>
  233. </div>
  234. </template>
  235. <script>
  236. import {addSop, courseList, updateSop, getSop} from "@/api/app/sop/info";
  237. import {getList} from "@/api/app/cpsc";
  238. import {getSopTemp} from '@/api/app/sop/template';
  239. import CusRoleList from '@/views/app/user/CusRoleList.vue';
  240. import {listRole} from '@/api/app/user/userList';
  241. import ImageUpload from "@/views/app/sop/info/ImageUpload";
  242. import selectTag from "@/views/app/tagGroup/selectTag.vue";
  243. import { getTagByIds, listTagGroupForUserBindTag as searchTags, } from "@/api/app/tag/tagGroup";
  244. import SopTemp from "@/views/app/sop/template/sopTemp.vue";
  245. export default {
  246. name: "addSop",
  247. components: { SopTemp, CusRoleList, ImageUpload, selectTag },
  248. data() {
  249. return {
  250. miniAppList: [],
  251. changeDate: '2025-08-20',
  252. changeRange: null,
  253. changeBusy: [
  254. { startMs: new Date('2025-08-20 12:00').getTime(), endMs: new Date('2025-08-20 13:30').getTime() }
  255. ],
  256. autoSopTypeOptions: [],
  257. //模板遮罩
  258. tempOpen: false,
  259. // 选中数组
  260. ids: [],
  261. courseList: [],
  262. tags: null,
  263. setting: [],
  264. //标签
  265. changeTagDialog: {
  266. title: "",
  267. open: false,
  268. type: null,
  269. },
  270. //选择的标签
  271. tagsIdsChangeSelectList: null,
  272. queryTagParams: {
  273. pageNum: 1,
  274. pageSize: 10,
  275. total: 0,
  276. name: null,
  277. },
  278. // 总条数
  279. total: 0,
  280. // 弹出层标题
  281. title: "",
  282. // 是否显示弹出层
  283. open: false,
  284. // 状态字典
  285. statusOptions: [],
  286. //SOP发送类型
  287. sopSendTypeOptions: [],
  288. // 表单参数
  289. form: {
  290. status: 1,
  291. filterMode: 1,
  292. sendType: 2,
  293. type: 2,
  294. filterType: 2,
  295. expiryTime: 3,
  296. autoGroup: 0,
  297. isAutoSop: 1,
  298. tempId: null,
  299. tempName: null,
  300. autoSopTime: { autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2, autoDateTime: [] },
  301. },
  302. selected: [],
  303. //选择客服对话框
  304. customerConfig: {
  305. title: "",
  306. visible: false
  307. },
  308. // 表单校验
  309. rules: {
  310. name: [{ required: true, message: "名称不能为空", trigger: "submit" }],
  311. type: [{ required: true, message: "不能为空", trigger: "submit" }],
  312. sendType: [{ required: true, message: "不能为空", trigger: "submit" }],
  313. startTime: [{ required: true, message: "开始时间不能为空", trigger: "submit" }],
  314. tempId: [{ required: true, message: "模板不能为空", trigger: "submit" }],
  315. tags: [
  316. {
  317. validator: this.validateGroupLevelOrTags,
  318. trigger: ["blur", "change"]
  319. }
  320. ],
  321. },
  322. opType: 0,//操作类型,0-新增(默认),1-编辑,2-查看
  323. formId: null,
  324. selectTagDialog: {
  325. visible: false,
  326. selected: [],
  327. },
  328. };
  329. },
  330. created() {
  331. this.getDicts("app_sop_status").then(response => {
  332. this.statusOptions = response.data;
  333. });
  334. this.getDicts("app_sop_type").then(response => {
  335. this.sopSendTypeOptions = response.data;
  336. });
  337. this.getDicts("app_sop_autoType").then(response => {
  338. this.autoSopTypeOptions = response.data;
  339. });
  340. //操作类型
  341. let opType = this.$route.params && this.$route.params.type;
  342. if (opType) {
  343. this.opType = opType;
  344. }
  345. //编辑/查看时有效
  346. let id = this.$route.params && this.$route.params.id;
  347. if (id) {
  348. this.formId = id;
  349. this.handleUpdate(id);
  350. }
  351. courseList().then(response => {
  352. this.courseList = response.list;
  353. });
  354. getList().then(response => {
  355. });
  356. },
  357. watch: {
  358. selected(newList) {
  359. this.form.appCustomerId = newList.map(item => item.id);
  360. }
  361. },
  362. methods: {
  363. validateGroupLevelOrTags(rule, value, callback) {
  364. // 检查是否是群聊筛选方式且自动创建群为1
  365. if (this.form.filterMode == 2 && this.form.autoGroup == 1) {
  366. // 检查评级数组和标签数组是否都为空
  367. const hasLevel = this.form.autoGroupLevelArray && this.form.autoGroupLevelArray.length > 0;
  368. const hasTags = this.tagsIdsChangeSelectList && this.tagsIdsChangeSelectList.length > 0;
  369. if (!hasLevel && !hasTags) {
  370. callback(new Error('创建群聊评级和企微标签必须至少选择一项'));
  371. } else {
  372. callback();
  373. }
  374. } else {
  375. // 如果不满足条件,验证通过
  376. callback();
  377. }
  378. },
  379. /** 打开子组件的选择器 */
  380. openPicker() {
  381. this.$refs.timePicker.openPicker();
  382. },
  383. fmt(ms) {
  384. if (!ms) return "-";
  385. const d = new Date(ms);
  386. return d.toLocaleTimeString("zh-CN", { hour12: false });
  387. },
  388. /**
  389. * 取消选择标签
  390. */
  391. tagCancel() {
  392. this.resetSearchQueryTag();
  393. this.changeTagDialog.open = false;
  394. },
  395. /**
  396. * 选择标签
  397. */
  398. hangleChangeTags() {
  399. this.selectTagDialog.visible = true;
  400. },
  401. /**
  402. * 绑定标签取消
  403. */
  404. tagCancelForBind() {
  405. this.selectTagDialog.visible = false;
  406. },
  407. /**
  408. * 绑定标签确认
  409. */
  410. tagSubmitForBind() {
  411. this.selectTagDialog.visible = false;
  412. },
  413. /**
  414. * 选中的绑定标签列表
  415. * @param group 标签所属组
  416. * @param tag 具体操作的标签
  417. */
  418. tagSelectionChangeCallForBind(group, tag) {
  419. if (!tag.isSelected) {
  420. this.selectTagDialog.selected = this.selectTagDialog.selected.filter(item => tag.id != item.id);
  421. } else {
  422. if (!this.selectTagDialog.selected.some(st => st.id == tag.id)) {
  423. this.selectTagDialog.selected.push(tag);
  424. }
  425. }
  426. },
  427. /**
  428. * 删除一些选择的标签
  429. * @param list
  430. */
  431. handleCloseTags(ruleItem) {
  432. const index = this.selectTagDialog.selected.findIndex(t => t === ruleItem);
  433. if (index !== -1) {
  434. this.selectTagDialog.selected.splice(index, 1);
  435. }
  436. },
  437. /**
  438. * 开始时间发生变化
  439. */
  440. clearAutoDatesIfNeeded() {
  441. if (this.form.autoSopTime.autoDateTime.length > 0 && (this.form.autoSopTime.autoSopType == 3 || this.form.autoSopTime.autoSopType == 4)) {
  442. // 1. 过滤掉 < startTime 的日期
  443. const validDates = this.form.autoSopTime.autoDateTime.filter(date => new Date(date) >= new Date(this.form.startTime));
  444. // 2. 如果有被过滤掉的日期,提示用户
  445. if (validDates.length < this.form.autoSopTime.autoDateTime.length) {
  446. this.$message.warning(`已自动移除小于 ${this.form.startTime} 的日期!`);
  447. }
  448. // 3. 升序排序
  449. validDates.sort((a, b) => new Date(a) - new Date(b));
  450. // 4. 更新数据
  451. this.form.autoSopTime.autoDateTime = validDates;
  452. }
  453. },
  454. /**
  455. * 开始时间,任务开始时间排序
  456. * @param dates
  457. */
  458. sortSelectedDates(dates) {
  459. if (!this.form.startTime) {
  460. this.$message.error("请先选择开始时间!不得小于任务开始时间");
  461. this.form.autoSopTime.autoDateTime = [];
  462. return;
  463. }
  464. // 1. 过滤掉 < startTime 的日期
  465. const validDates = dates.filter(date => new Date(date) >= new Date(this.form.startTime));
  466. // 2. 如果有被过滤掉的日期,提示用户
  467. if (validDates.length < dates.length) {
  468. this.$message.warning(`已自动移除小于 ${this.form.startTime} 的日期!`);
  469. }
  470. // 3. 升序排序
  471. validDates.sort((a, b) => new Date(a) - new Date(b));
  472. // 4. 更新数据
  473. this.form.autoSopTime.autoDateTime = validDates;
  474. },
  475. /**
  476. * 查询模板
  477. * @param type
  478. */
  479. selectListSopTemp(type) {
  480. this.tempOpen = true;
  481. setTimeout(() => {
  482. this.$refs.SopTempComments.getList(type);
  483. }, 200);
  484. },
  485. sopTemp(val) {
  486. this.$set(this.form, 'tempId', val.id);
  487. this.$set(this.form, 'tempName', val.name);
  488. this.tempOpen = false;
  489. },
  490. //选择app用户时
  491. openSelectCustomerPage(type, sendType) {
  492. this.customerConfig.title = "选择客服"
  493. this.customerConfig.visible = true;
  494. },
  495. /**
  496. * 切换类别时 ,清除选择的成员
  497. */
  498. clearUser() {
  499. this.selected = [];
  500. this.tags = null;
  501. },
  502. /**
  503. * 编辑/查看获取任务信息
  504. * @param sopId
  505. */
  506. handleUpdate(sopId) {
  507. this.reset();
  508. getSop({id: sopId}).then(async (response) => {
  509. this.form = response.data;
  510. this.form.autoSopTime = JSON.parse(response.data.autoSopTime)
  511. if (this.form.filterMode != 1) {
  512. this.form.sendType = 2;
  513. }
  514. if (!this.isEmpty(this.form.tags)) {
  515. let tagInfo = await getTagByIds(this.form.tags);
  516. this.selectTagDialog.selected = tagInfo.data || [];
  517. }
  518. this.form.status = response.data.status.toString();
  519. if (this.form.setting != null) {
  520. this.setting = JSON.parse(this.form.setting);
  521. }
  522. if (this.form.autoGroupLevel != null) {
  523. this.form.autoGroupLevelArray = this.form.autoGroupLevel.split(",").map(Number)
  524. .filter(item => item !== 0);
  525. }
  526. if (!this.isEmpty(this.form.appCustomerId)) {
  527. let userInfo = await listRole({ids: this.form.appCustomerId});
  528. this.selected = userInfo.rows;
  529. }
  530. let tempInfo = await getSopTemp(this.form.tempId);
  531. this.$set(this.form, 'tempName', tempInfo.data.name);
  532. });
  533. },
  534. isEmpty(obj) {
  535. if (null === obj || undefined === obj || 0 === obj.length) {
  536. return true;
  537. }
  538. return false;
  539. },
  540. customerSelectedConfirmCallForBind() {
  541. this.customerConfig.visible = false;
  542. },
  543. /**
  544. * 选中的用户列表
  545. * @param list
  546. */
  547. customerSelectionChangeCallForBind(config) {
  548. let selected = config.selected;
  549. //单行操作
  550. if (config.mode === 0) {
  551. let row = config.row;
  552. if (selected) {
  553. if (!this.selected.some(s => s.id == row.id)) {
  554. this.selected.push(row)
  555. }
  556. } else {
  557. this.selected = this.selected.filter(m => m.id != row.id);
  558. }
  559. }
  560. //操作当前页所有行
  561. else {
  562. let list = config.rows;
  563. if (selected) {
  564. list.map(l => {
  565. if (!this.selected.some(s => s.id == l.id)) {
  566. this.selected.push(l)
  567. }
  568. });
  569. } else {
  570. list.map(l => {
  571. for (let i = 0; i < this.selected.length; i++) {
  572. if (l.id == this.selected[i].id) {
  573. this.selected.splice(i, 1);
  574. }
  575. }
  576. })
  577. }
  578. }
  579. },
  580. //选择变动时的变动
  581. /**
  582. * 推送方式修改
  583. * @param val
  584. */
  585. handleSendTypeChange(val) {
  586. this.selected = [];
  587. this.form.tempId = null;
  588. this.form.tempName = null;
  589. if (val == 1) {
  590. // 遍历 this.setting 数组并清空每个对象的 content 属性
  591. this.setting.forEach(item => {
  592. if (item.content.length > 9) {
  593. item.content = item.content.slice(0, 9); // 保留前 9 个元素
  594. }
  595. });
  596. }
  597. },
  598. handleCloseCustomer(list) {
  599. const index = this.selected.findIndex(t => t === list);
  600. if (index !== -1) {
  601. this.selected.splice(index, 1);
  602. }
  603. },
  604. /**
  605. * 取消按钮
  606. */
  607. cancel() {
  608. //删除当前打开的菜单tab
  609. this.$store.dispatch("tagsView/delView", this.$route);
  610. //替换浏览器路由
  611. this.$router.replace('/app/sop')
  612. this.reset();
  613. },
  614. /**
  615. * 清空搜索标签条件
  616. */
  617. resetSearchQueryTag() {
  618. this.queryTagParams = {
  619. pageNum: 1,
  620. pageSize: 10,
  621. total: 0,
  622. name: null,
  623. };
  624. },
  625. // 表单重置
  626. reset() {
  627. this.form = {
  628. id: null,
  629. filterMode: 1,
  630. name: null,
  631. status: 1,
  632. sendType: 2,
  633. filterType: 2,
  634. expiryTime: 3,
  635. appCustomerId: null,
  636. setting: null,
  637. createBy: null,
  638. createTime: null,
  639. autoSopTime: { autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2, autoDateTime: [] },
  640. };
  641. this.resetForm("form");
  642. this.tags = null;
  643. },
  644. /** 重置按钮操作 */
  645. resetQuery() {
  646. this.resetForm("queryForm");
  647. this.handleQuery();
  648. },
  649. formatDateTo24HourString(date) {
  650. let year = date.getFullYear();
  651. let month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份需要加 1 并补零
  652. let day = ('0' + date.getDate()).slice(-2); // 日需要补零
  653. let hours = ('0' + date.getHours()).slice(-2); // 小时需要补零
  654. let minutes = ('0' + date.getMinutes()).slice(-2); // 分钟需要补零
  655. let seconds = ('0' + date.getSeconds()).slice(-2); // 秒需要补零
  656. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  657. },
  658. // 打开群聊选择器
  659. openGroupChatSelector() {
  660. this.$refs.groupChatSelector.show(this.form.chatIds);
  661. },
  662. // 处理群聊选择结果
  663. handleSelectGroupChats(selectedChatIds) {
  664. this.form.chatIds = selectedChatIds;
  665. // 强制更新视图
  666. this.$forceUpdate();
  667. },
  668. /**
  669. * 保存sop任务
  670. */
  671. submitForm() {
  672. this.$refs["form"].validate(valid => {
  673. if (valid) {
  674. if (this.selected.length <= 0) {
  675. return this.$message.error("请选择客服")
  676. }
  677. this.form.appCustomerId = this.selected.map(s => s.id).join(",");
  678. if (this.selectTagDialog.selected != null && this.selectTagDialog.selected.length > 0) {
  679. this.form.tags = this.selectTagDialog.selected?.map(item => item.id).join(",");
  680. } else {
  681. return this.$message.error("选择的标签不能为空!!请选择筛选的标签")
  682. }
  683. if (this.form.autoSopTime.autoSopType == 3 || this.form.autoSopTime.autoSopType == 4) {
  684. if (this.form.autoSopTime.autoDateTime == null || this.form.autoSopTime.autoDateTime == "") {
  685. return this.$message.error("选择的日期不能为空!!请选择日期")
  686. }
  687. }
  688. this.form.appCustomerId = this.selected.map(s => s.id).join(",");
  689. this.form.setting = JSON.stringify(this.setting)
  690. this.form.autoSopTime.createTime = this.formatDateTo24HourString(new Date());
  691. this.form.autoSopTime = JSON.stringify(this.form.autoSopTime)
  692. if (this.form.id != null) {
  693. updateSop(this.form).then(response => {
  694. this.msgSuccess("修改成功");
  695. this.$store.dispatch("tagsView/delView", this.$route);
  696. window.location.replace('/app/sop')
  697. this.reset();
  698. });
  699. } else {
  700. addSop(this.form).then(response => {
  701. this.msgSuccess("新增成功");
  702. this.$store.dispatch("tagsView/delView", this.$route);
  703. window.location.replace('/app/sop')
  704. this.reset();
  705. });
  706. }
  707. }
  708. });
  709. },
  710. }
  711. };
  712. </script>
  713. <style scoped lang="scss">
  714. .custom-input ::v-deep .el-input__inner {
  715. height: 20px;
  716. padding: 0 4px;
  717. text-align:center;
  718. display: block;
  719. }
  720. .custom-input ::v-deep .el-input__icon {
  721. line-height: 20px;
  722. }
  723. .user-box {
  724. width: 50px; /* 盒子宽度 */
  725. height: 30px; /* 盒子高度 */
  726. padding: 5px 10px; /* 内边距 */
  727. border: 1px solid #d5d1d1;/* 边框 */
  728. margin: 3px; /* 外边距 */
  729. background-color: #f9f9f9;/* 背景颜色 */
  730. color: #333; /* 文本颜色 */
  731. font-size: 14px; /* 字体大小 */
  732. text-align: center; /* 文本居中 */
  733. }
  734. .elFormItemClass{
  735. margin: 20px 0px
  736. }
  737. .message-stayle{
  738. display: flex;
  739. justify-content: normal;
  740. align-items: center;
  741. margin-top: 10px;
  742. }
  743. .message-stayle .el-link {
  744. white-space: normal; /* 允许换行 */
  745. word-break: break-all; /* 单词中间断行 */
  746. overflow-wrap: break-word; /* 允许在单词内换行 */
  747. }
  748. .message-stayle span {
  749. word-break: break-all;
  750. }
  751. .container {
  752. position: relative; /* 使 phone div 的 absolute 定位基于这个容器 */
  753. width: 100%;
  754. height: 100%;
  755. }
  756. .phone {
  757. position: absolute; /* 定位到容器内 */
  758. top: 5%;
  759. left: 50%;
  760. transform: translateX(-50%);
  761. width: 100%;
  762. max-width: 375px;
  763. height: 100%;
  764. max-height: 90%;
  765. border: 8px solid #ccc;
  766. border-radius: 36px;
  767. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  768. background-color: #fff;
  769. overflow: hidden;
  770. }
  771. .phone::before {
  772. content: '';
  773. position: absolute;
  774. top: 0;
  775. left: 50%;
  776. width: 60px;
  777. height: 5px;
  778. background-color: #ccc;
  779. border-radius: 10px;
  780. transform: translateX(-50%);
  781. }
  782. .chat-interface {
  783. display: flex;
  784. flex-direction: column;
  785. height: 100%;
  786. background-color: #fff;
  787. }
  788. .header {
  789. display: flex;
  790. justify-content: space-between;
  791. align-items: center;
  792. height: 50px;
  793. padding: 0 15px;
  794. background-color: #fff;
  795. border-bottom: 1px solid #e0e0e0;
  796. }
  797. .header .back,
  798. .header .menu {
  799. height: 25px;
  800. width: 25px;
  801. }
  802. .header .title{
  803. font-size: 16px;
  804. margin: auto;
  805. }
  806. .message-area {
  807. flex: 1;
  808. background-color: rgb(240, 242, 245);
  809. padding: 10px;
  810. overflow-y: auto;
  811. }
  812. .footer {
  813. display: flex;
  814. align-items: center;
  815. padding: 10px;
  816. background-color: #fff;
  817. border-top: 1px solid #e0e0e0;
  818. }
  819. .footer .voice-button,
  820. .footer .emoji-button,
  821. .footer .add-button {
  822. width: 25px;
  823. height: 25px;
  824. border: none;
  825. cursor: pointer;
  826. flex-shrink: 0; /* 不允许缩小 */
  827. }
  828. .footer .emoji-button,
  829. .footer .add-button {
  830. margin: 0px 5px;
  831. }
  832. .footer .input-box {
  833. flex: 1;
  834. border: 1px solid #e0e0e0;
  835. margin-left: 5px;
  836. }
  837. .text-container {
  838. max-height: 7.5em; /* 设置最大高度为6行,根据字体大小调整 */
  839. overflow-y: auto; /* 内容超出时显示滚动条 */
  840. line-height: 1.5em; /* 行高设置,确保每行高度一致 */
  841. }
  842. .el-form-item {
  843. margin-bottom: 30px;
  844. }
  845. .custom-span {
  846. display: block; /* 确保元素是块级元素 */
  847. height: 110px; /* 设置固定高度 */
  848. overflow-y: auto; /* 超出高度时显示滚动条 */
  849. word-wrap: break-word; /* 自动换行 */
  850. word-break: break-all; /* 在必要时进行换行 */
  851. }
  852. .custom-span-description{
  853. display: block; /* 确保元素是块级元素 */
  854. height: 110px; /* 设置固定高度 */
  855. overflow-y: auto; /* 超出高度时显示滚动条 */
  856. word-wrap: break-word; /* 自动换行 */
  857. word-break: break-all; /* 在必要时进行换行 */
  858. }
  859. .custom-span-title {
  860. display: block; /* 确保元素是块级元素 */
  861. height: 45px; /* 设置固定高度 */
  862. overflow-y: auto; /* 超出高度时显示滚动条 */
  863. word-wrap: break-word; /* 自动换行 */
  864. word-break: break-all; /* 在必要时进行换行 */
  865. }
  866. /* CSS 样式 */
  867. .tag-container {
  868. display: flex;
  869. flex-wrap: wrap; /* 超出宽度时自动换行 */
  870. gap: 8px; /* 设置标签之间的间距 */
  871. }
  872. .name-background {
  873. display: inline-block;
  874. background-color: #abece6; /* 背景颜色 */
  875. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  876. border-radius: 4px; /* 可选:设置圆角 */
  877. }
  878. .tag-box {
  879. padding: 8px 12px;
  880. border: 1px solid #989797;
  881. border-radius: 4px;
  882. cursor: pointer;
  883. display: inline-block;
  884. }
  885. .tag-selected {
  886. background-color: #00bc98;
  887. color: #fff;
  888. border-color: #00bc98;
  889. }
  890. .el-tag + .el-tag {
  891. margin-left: 10px;
  892. }
  893. .button-new-tag {
  894. margin-left: 10px;
  895. height: 32px;
  896. line-height: 30px;
  897. padding-top: 0;
  898. padding-bottom: 0;
  899. }
  900. .input-new-tag {
  901. width: 90px;
  902. margin-left: 10px;
  903. vertical-align: bottom;
  904. }
  905. .text-container {
  906. max-height: 5em; /* 设置最大高度为6行,根据字体大小调整 */
  907. overflow-y: auto; /* 内容超出时显示滚动条 */
  908. line-height: 1.5em; /* 行高设置,确保每行高度一致 */
  909. }
  910. </style>