index.vue 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603
  1. <template>
  2. <div class="app-container">
  3. <!-- 过滤条件 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="规则编号" prop="id">
  6. <el-input v-model="queryParams.id" placeholder="请输入规则名称" clearable size="small"
  7. @keyup.enter.native="handleQuery" />
  8. </el-form-item>
  9. <el-form-item label="规则状态 " prop="status">
  10. <el-select v-model="queryParams.status" placeholder="请选择规则状态" clearable size="small"
  11. @change="updateCorpId()">
  12. <el-option v-for="dict in sysSopStatus" :key="dict.dictValue" :label="dict.dictLabel"
  13. :value="dict.dictValue" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="发送方式 " prop="sendType">
  17. <el-select v-model="queryParams.sendType" placeholder="请选择发送方式状态" clearable size="small"
  18. @change="updateCorpId()">
  19. <el-option v-for="dict in appSopType" :key="dict.dictValue" :label="dict.dictLabel"
  20. :value="dict.dictValue" />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="名称" prop="name">
  24. <el-input v-model="queryParams.name" placeholder="请输入规则名称" clearable size="small"
  25. @keyup.enter.native="handleQuery" />
  26. </el-form-item>
  27. <el-form-item label="创建时间" prop="createTime">
  28. <el-date-picker clearable size="small" v-model="queryParams.createTime" type="date"
  29. value-format="yyyy-MM-dd" placeholder="选择创建时间">
  30. </el-date-picker>
  31. </el-form-item>
  32. <el-form-item label="标签" prop="tagIds">
  33. <div @click="hangleChangeTags()"
  34. style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 250px">
  35. <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
  36. <el-tag type="success" closable :disable-transitions="false" v-for="list in this.selectTags"
  37. :key="list.id" @close="handleCloseTags(list)" style="margin: 3px;">{{ list.name }}
  38. </el-tag>
  39. </div>
  40. </div>
  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. <!-- 工具栏 -->
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['app:sop:add']"
  57. >
  58. 新增
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="danger"
  64. plain
  65. icon="el-icon-delete"
  66. size="mini"
  67. :disabled="multiple"
  68. @click="handleDelete"
  69. v-hasPermi="['app:sop:delete']"
  70. >
  71. 删除
  72. </el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="success"
  77. plain
  78. icon="el-icon-download"
  79. size="mini"
  80. :loading="exportLoading"
  81. @click="handleExport"
  82. v-hasPermi="['app:sop:export']"
  83. >
  84. 导出
  85. </el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. size="mini"
  90. plain
  91. type="warning"
  92. icon="el-icon-edit"
  93. :disabled="multiple"
  94. @click="handleExecute"
  95. v-hasPermi="['app:sop:exec']"
  96. >
  97. 批量执行自动化
  98. </el-button>
  99. </el-col>
  100. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  101. </el-row>
  102. <!-- 数据表格 -->
  103. <el-table v-loading="loading" border :data="sopList" @selection-change="handleSelectionChange">
  104. <el-table-column type="selection" width="55" align="center" />
  105. <el-table-column label="规则编号" align="center" prop="id" min-width="160" />
  106. <el-table-column label="规则名称" align="center" prop="name" min-width="150" />
  107. <el-table-column label="规则状态" align="center" prop="status" min-width="150">
  108. <template slot-scope="scope">
  109. <dict-tag :options="sysSopStatus" :value="scope.row.status"></dict-tag>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="发送方式" align="center" prop="sendType">
  113. <template slot-scope="scope">
  114. <dict-tag :options="appSopType" :value="scope.row.sendType" />
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="模板" align="center" prop="tempId">
  118. <template slot-scope="scope">
  119. <div v-for="id in tempList" v-if="id.id == scope.row.tempId">{{ id.name }}</div>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="新客户自动创建自动化" align="center" prop="isAutoSop" min-width="180">
  123. <template slot-scope="scope">
  124. <el-switch v-if="scope.row.sendType == 2 || scope.row.sendType != 4" v-model="scope.row.isAutoSop"
  125. active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2"
  126. @change="switchAutoSopChange(scope.row, scope.row.isAutoSop)">
  127. </el-switch>
  128. <span v-if="scope.row.sendType != 1 && scope.row.sendType != 4 && scope.row.isAutoSop == '1'"
  129. style="margin-left: 10px;color: #13ce66">已开启</span>
  130. <span v-if="scope.row.sendType != 1 && scope.row.sendType != 4 && scope.row.isAutoSop == '2'"
  131. style="margin-left: 10px;color: #ff4949">已关闭</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="过期时间" align="center" prop="expiryTime">
  135. <template slot-scope="scope">
  136. {{ scope.row.expiryTime }} 小时
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
  140. <el-table-column label="修改规则状态时间" align="center" prop="stopTime" min-width="180" />
  141. <el-table-column label="查看操作" align="center" class-name="small-padding fixed-width" min-width="200"
  142. fixed="right">
  143. <!-- 任务状态为 非待执行 则有以下操作-->
  144. <template slot-scope="scope">
  145. <el-button
  146. v-if="[0, 2, 3, 4].includes(Number(scope.row.status)) && scope.row.sendType != 4"
  147. size="mini" type="text" @click="selectSchedule(scope.row)">营期
  148. </el-button>
  149. <el-button
  150. v-if="[0, 2, 3, 4].includes(Number(scope.row.status)) || scope.row.sendType == 4"
  151. size="mini" type="text" style="color: green;" @click="handleScheduleDetail(scope.row)">执行详情
  152. </el-button>
  153. <el-button
  154. v-if="[0, 2, 3, 4].includes(Number(scope.row.status))"
  155. size="mini" type="text" @click="handleUpdate(scope.row, 2)">查看规则
  156. </el-button>
  157. <el-button
  158. v-if="[0, 2, 3, 4].includes(Number(scope.row.status))"
  159. size="mini" type="text" style="color: green;" @click="handleQueryDetails(scope.row)">查看模板
  160. </el-button>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="修改操作" align="center" class-name="small-padding fixed-width" min-width="100"
  164. fixed="right">
  165. <template slot-scope="scope">
  166. <el-button
  167. v-if="scope.row.sendType != 4"
  168. size="mini"
  169. type="text"
  170. @click="handleUpdateOutTime(scope.row)"
  171. v-hasPermi="['app:sop:edit']"
  172. >
  173. 修改规则
  174. </el-button>
  175. <el-button
  176. v-if="scope.row.status == 1"
  177. size="mini"
  178. type="text"
  179. @click="handleUpdate(scope.row, 1)"
  180. v-hasPermi="['app:sop:edit']"
  181. >
  182. 修改任务
  183. </el-button>
  184. <el-button
  185. size="mini"
  186. type="text"
  187. style="color: red;"
  188. @click="handleDelete(scope.row)"
  189. v-hasPermi="['app:sop:delete']"
  190. >删除
  191. </el-button>
  192. </template>
  193. </el-table-column>
  194. </el-table>
  195. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  196. @pagination="getList" />
  197. <!-- 添加或修改sop对话框 -->
  198. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  199. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  200. <el-form-item label="规则名称" prop="name">
  201. <el-input v-model="form.name" placeholder="请输入规则名称" />
  202. </el-form-item>
  203. <el-form-item label="状态">
  204. <el-radio-group v-model="form.status">
  205. <el-radio v-for="dict in statusOptions" :key="dict.dictValue"
  206. :label="parseInt(dict.dictValue)">{{ dict.dictLabel }}
  207. </el-radio>
  208. </el-radio-group>
  209. </el-form-item>
  210. <el-form-item label="开始时间" prop="startTime">
  211. <el-date-picker clearable size="small" v-model="form.startTime" type="date"
  212. value-format="yyyy-MM-dd" placeholder="选择开始时间">
  213. </el-date-picker>
  214. </el-form-item>
  215. <el-form-item label="模板" prop="tempId">
  216. <el-select v-model="form.tempId" @focus="selectListSopTemp(form.sendType)" placeholder="请选择模板"
  217. v-loading="tempListLoading">
  218. <el-option v-for="dict in tempList" :label="dict.name" :value="dict.id">
  219. </el-option>
  220. <div v-if="tempListLoading" slot="prefix" class="select-prefix">正在查询相应模板...</div>
  221. </el-select>
  222. </el-form-item>
  223. </el-form>
  224. <div slot="footer" class="dialog-footer">
  225. <el-button type="primary" @click="submitForm">确 定</el-button>
  226. <el-button @click="cancel">取 消</el-button>
  227. </div>
  228. </el-dialog>
  229. <el-dialog :title="changeTagDialog.title" :visible.sync="changeTagDialog.open" width="1000px" append-to-body>
  230. <div>搜索标签:
  231. <el-input v-model="queryTagParams.name" placeholder="请输入标签名称" clearable size="small"
  232. style="width: 200px;margin-right: 10px" />
  233. <el-button type="primary" icon="el-icon-search" size="mini"
  234. @click="handleSearchTags(queryTagParams.name)">
  235. 搜索
  236. </el-button>
  237. <el-button type="primary" icon="el-icon-refresh" size="mini" @click="cancelSearchTags">重置</el-button>
  238. </div>
  239. <div v-for="item in tagGroupList" :key="item.id">
  240. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  241. <span class="name-background">{{ item.name }}</span>
  242. </div>
  243. <div class="tag-container">
  244. <a v-for="tagItem in item.tags" class="tag-box" @click="tagSelection(tagItem)"
  245. :class="{ 'tag-selected': tagItem.isSelected || (selectTags && selectTags.some(tg => tg.id == tagItem.id)) }">
  246. {{ tagItem.name }}
  247. </a>
  248. </div>
  249. </div>
  250. <pagination v-show="tagTotal > 0" :total="tagTotal" :page.sync="queryTagParams.pageNum"
  251. :limit.sync="queryTagParams.pageSize" @pagination="getPageListTagGroup" />
  252. <div slot="footer" class="dialog-footer">
  253. <el-button type="primary" @click="tagSubmitForm()">确 定</el-button>
  254. <el-button @click="tagCancel()">取消</el-button>
  255. </div>
  256. </el-dialog>
  257. <!-- 单独的修改时间 -->
  258. <el-dialog :title="outTimeOpen.title" :visible.sync="outTimeOpen.open" width="800px">
  259. <el-card class="box-card">
  260. <el-row>
  261. <el-col style="margin-top: 3%; display: flex;">
  262. <span style="font-size: 16px;font-weight: bold; width: 120px; display: flex; align-items: center; justify-content: end;">过期时间:</span>
  263. <el-input-number v-model="outTimeOpen.expiryTime" :min="1" :max="100"/>
  264. <span style="font-size: 16px;font-weight: bold; display: flex; align-items: center; justify-content: end;">(小时)</span>
  265. </el-col>
  266. <el-col style="margin-top: 3%; display: flex;">
  267. <span style="font-size: 16px;font-weight: bold; width: 120px; display: flex; align-items: center; justify-content: end;">次要节点天数:</span>
  268. <el-input v-model="outTimeOpen.minConversionDay" style="width: 200px;"/>
  269. <span style="font-size: 16px;font-weight: bold; display: flex; align-items: center; justify-content: end;">(天)</span>
  270. </el-col>
  271. <el-col style="margin-top: 3%; display: flex;">
  272. <span style="font-size: 16px;font-weight: bold; width: 120px; display: flex; align-items: center; justify-content: end;">重要节点天数:</span>
  273. <el-input v-model="outTimeOpen.maxConversionDay" style="width: 200px;"/>
  274. <span style="font-size: 16px;font-weight: bold; display: flex; align-items: center; justify-content: end;">(天)</span>
  275. </el-col>
  276. <el-col style="margin-top: 3%;">
  277. <span style="font-size: 16px;font-weight: bold;">发课开始天数:</span>
  278. <el-input-number v-model="outTimeOpen.courseDay" :min="1" :max="100"></el-input-number>
  279. (天)
  280. <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-top: 2%">
  281. <i class="el-icon-info"></i>
  282. 作用于【提醒看板】和【学习记录】的统计,由多少天开始计算。比如 模板里
  283. 第一天是先导课,第二天是正课,此处设置天数为2,则统计从第二天开始。如果无视模板天数,此处设置几天,则统计面板就从第几天开始统计
  284. </div>
  285. </el-col>
  286. <el-col style="margin: 3% ">
  287. <div style="float: right;margin-right: 3%">
  288. <el-button type="primary" icon="el-icon-search" size="mini"
  289. @click="handleUpdateExpiryTime">确定修改
  290. </el-button>
  291. <el-button icon="el-icon-refresh" size="mini" @click="resetUpdateExpiryTime">取消</el-button>
  292. </div>
  293. </el-col>
  294. </el-row>
  295. </el-card>
  296. </el-dialog>
  297. <!-- -->
  298. <el-dialog :title="autoSopOpen.title" :visible.sync="autoSopOpen.open" width="1300px" append-to-body>
  299. <el-form ref="autoSopTimeFrom" :model="form.autoSopTime" :rules="autoSopTimeRules">
  300. <el-form-item label="自动类型" prop="type" style="margin: 2%; display: flex; align-items: center;">
  301. <el-radio-group v-model="form.autoSopTime.autoSopType">
  302. <el-radio :label="Number(dict.dictValue)" v-for="dict in autoSopTypeOptions">{{ dict.dictLabel }}</el-radio>
  303. </el-radio-group>
  304. </el-form-item>
  305. <div style="display: flex; align-items: center; flex-wrap: nowrap;">
  306. <div v-if="form.autoSopTime.autoSopType == 1" style="display: flex; align-items: center">
  307. <el-form-item label="起始时间" prop="autoStartTime" label-width="100px"
  308. style="margin: 2% 0;align-items: center;">
  309. <el-time-select style="width: 120px;" placeholder="起始时间"
  310. v-model="form.autoSopTime.autoStartTime" :picker-options="{
  311. start: '00:00',
  312. step: '00:15',
  313. end: '24:00'
  314. }">
  315. </el-time-select>
  316. </el-form-item>
  317. <el-form-item label="结束时间" prop="autoEndTime" label-width="100px"
  318. style="margin: 2% 0; align-items: center; ">
  319. <el-time-select style="width: 120px;" placeholder="结束时间"
  320. v-model="form.autoSopTime.autoEndTime" :picker-options="{
  321. start: '00:00',
  322. step: '00:15',
  323. end: '24:00',
  324. minTime: form.autoSopTime.autoEndTime
  325. }">
  326. </el-time-select>
  327. </el-form-item>
  328. </div>
  329. </div>
  330. <el-form-item v-if="form.autoSopTime.autoSopType == 1" label="过期消息是否发送" prop="autoSopSend"
  331. style="margin: 2%; display: flex; align-items: center;">
  332. <el-radio-group v-model="form.autoSopTime.autoSopSend">
  333. <el-radio :label="1">是
  334. </el-radio>
  335. <el-radio :label="2">否
  336. </el-radio>
  337. </el-radio-group>
  338. </el-form-item>
  339. <div style="display: flex; align-items: center; flex-wrap: nowrap;"
  340. v-if="form.autoSopTime.autoSopType == 3 || form.autoSopTime.autoSopType == 4">
  341. <el-form-item label="选择一个或多个日期" prop="autoDateTime" label-width="150px">
  342. <el-date-picker size="large" type="dates" style="width: 600px"
  343. v-model="form.autoSopTime.autoDateTime" value-format="yyyy-MM-dd"
  344. placeholder="选择一个或多个日期【ps:请先选择开始时间,不得小于任务开始时间】"
  345. @change="sortSelectedDates(form.autoSopTime.autoDateTime)" :disabled="!form.startTime">
  346. </el-date-picker>
  347. </el-form-item>
  348. </div>
  349. <el-alert v-if="form.autoSopTime.autoSopType == 1" title="起始时间-结束时间之内的,当天立即创建自动化,时间之外的 次日创建自动化"
  350. type="warning" style="font-size: 30px; margin-top: 3%;" :closable="false" show-icon>
  351. </el-alert>
  352. <el-alert v-if="form.autoSopTime.autoSopType == 3" type="warning" style="margin-top: 3%;"
  353. :closable="false" show-icon>
  354. <template #title>
  355. <span style="font-size: 23px; line-height: 1.5;">
  356. 此功能用于正课区分营期,可以选择你想要开始营期的具体时间,选择后在此期间添加的用户将会自动进入对应营期。
  357. 例如今天1月1日,选择时间是1月1日,1月5日,1月10日。
  358. 用户1月1日-1月4日添加(添加上对应标签)则会进入1月5日的营期,1月5日-1月9日添加则会进入1月10日营期,1月5日自动给用户发送第一节科普
  359. </span>
  360. </template>
  361. </el-alert>
  362. <el-alert v-if="form.autoSopTime.autoSopType == 4" title="" type="warning"
  363. style="font-size: 30px; margin-top: 3%;" :closable="false" show-icon>
  364. <template #title>
  365. <span style="font-size: 23px; line-height: 1.5;">
  366. 此功能用于先导课区分营期,可以选择先导课开始营期的具体时间,选择后在此期间添加的用户将会自动进入对应营期。
  367. 例如今天1月1日,选择时间是1月1日,1月5日,1月10日。
  368. 用户1月1日-1月4日添加(添加上对应标签)则会进入1月1日的营期,1月5日-1月9日添加则会进入1月5日营期,自动给用户匹配上对应应该听到天数的时间节点
  369. </span>
  370. </template>
  371. </el-alert>
  372. </el-form>
  373. <div slot="footer" class="dialog-footer">
  374. <el-button type="primary" @click="submitAutoSopTimeFrom">确 定</el-button>
  375. <el-button @click="cancelAutoSopTime">取 消</el-button>
  376. </div>
  377. </el-dialog>
  378. <!-- 执行详情 -->
  379. <el-drawer :title="sopLogsDialog.title" :visible.sync="sopLogsDialog.open" size="85%"
  380. style="font-weight: bolder">
  381. <sopLogsDetails ref="sopLogsDetails" :rowDetailFrom="sopLogsDialog.sopLogsForm"></sopLogsDetails>
  382. </el-drawer>
  383. </div>
  384. </template>
  385. <script>
  386. import {
  387. addSop,
  388. courseList,
  389. videoList,
  390. delSop,
  391. exportSop,
  392. getSopVoiceList,
  393. listSop,
  394. updateAutoSopTime,
  395. getTempUserList,
  396. updateTemp,
  397. updateSop,
  398. updateSopStatus,
  399. updateStatus
  400. } from "@/api/app/sop/info";
  401. import {listSopTemp} from "@/api/app/sop/template";
  402. import ImageUpload from "@/views/app/sop/info/ImageUpload";
  403. import sopLogsDetails from '@/views/app/sop/userLogs/sopLogsList.vue'
  404. import { listTagGroupForUserBindTag, } from "@/api/app/tag/tagGroup";
  405. export default {
  406. name: "Sop",
  407. components: { ImageUpload, sopLogsDetails },
  408. data() {
  409. return {
  410. miniAppList: [],
  411. // 添加以下字段
  412. selectTags: [], // 已选择的标签
  413. tagGroupList: [], // 标签组列表
  414. tagTotal: 0, // 标签总数
  415. autoSopTypeOptions: [],
  416. // 标签弹窗相关
  417. changeTagDialog: {
  418. title: "",
  419. open: false,
  420. },
  421. queryTagParams: {
  422. pageNum: 1,
  423. pageSize: 10,
  424. total: 0,
  425. name: null,
  426. corpId: null,
  427. },
  428. luckyBagList: [],
  429. luckyBag: null,
  430. liveList: [],
  431. // 存储每一行的展开状态
  432. expandedRows: {},
  433. //模板查询
  434. tempListLoading: false,
  435. // 遮罩层
  436. loading: false,
  437. // 导出遮罩层
  438. exportLoading: false,
  439. // 选中数组
  440. ids: [],
  441. //选中的map
  442. selectionMap: {},
  443. myQwCompanyList: [],
  444. tempUser: {
  445. open: false,
  446. id: null,
  447. updateOpen: false,
  448. loading: true,
  449. list: [],
  450. form: {
  451. id: null,
  452. liveTempId: null,
  453. liveTempSendTime: null,
  454. },
  455. },
  456. //客服员工列表
  457. companyUserLists: [],
  458. videoList: [],
  459. uploadUrl: process.env.VUE_APP_BASE_API + "/app/common/uploadOSS",
  460. uploadUrlByVoice: process.env.VUE_APP_BASE_API + "/app/common/uploadOSSByHOOKVoice",
  461. msgForm: {
  462. videoId: null,
  463. courseId: null,
  464. courseType: null,
  465. userIdParam: null,
  466. sendType: 1,
  467. setting: null,
  468. ids: null,
  469. sopId: null,
  470. startTime: null,
  471. chatIds: [],
  472. isRegister: 2
  473. },
  474. msgRules: {},
  475. courseList: [],
  476. // videoList:[],
  477. tags: null,
  478. excludeTags: null,
  479. // 非单个禁用
  480. single: true,
  481. setting: [],
  482. tagList: [],
  483. tempList: [],
  484. // 非多个禁用
  485. multiple: true,
  486. // 显示搜索条件
  487. showSearch: true,
  488. // 总条数
  489. total: 0,
  490. // 企微sop表格数据
  491. sopList: [],
  492. // 弹出层标题
  493. title: "",
  494. // 是否显示弹出层
  495. open: false,
  496. companyUserList: [],
  497. // 状态字典
  498. statusOptions: [],
  499. //sop状态
  500. sysSopStatus: [],
  501. autoSopOpen: {
  502. title: '',
  503. open: false,
  504. id: null,
  505. isAutoSop: null,
  506. },
  507. outTimeOpen: {
  508. title: '',
  509. open: false,
  510. id: null,
  511. tempId: null,
  512. expiryTime: null,
  513. minConversionDay: null,
  514. maxConversionDay: null,
  515. isLiveMgs: 0,
  516. liveTempId: null,
  517. liveTempSendTime: null,
  518. appId: null
  519. },
  520. voiceForm: {
  521. list: [],
  522. open: false,
  523. total: 0,
  524. queryParams: {
  525. pageNum: 1,
  526. pageSize: 10,
  527. id: null,
  528. },
  529. },
  530. //SOP发送类型
  531. appSopType: [],
  532. chatList: [],
  533. //SOP科普观看状态
  534. sysFsSopWatchStatus: [],
  535. //插件版
  536. sysQwSopAiContentType: [],
  537. // 查询参数
  538. queryParams: {
  539. pageNum: 1,
  540. pageSize: 10,
  541. id: null,
  542. name: null,
  543. status: null,
  544. sendType: null,
  545. createTime: null,
  546. tagIds: null,
  547. },
  548. sopLogsDialog: {
  549. title: '',
  550. open: false,
  551. sopLogsForm: [],
  552. },
  553. // 表单参数
  554. form: {
  555. autoSopTime: { autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2, autoDateTime: [] },
  556. },
  557. courseLiveTempOption: [],
  558. userSelectList: [],
  559. listUser: {
  560. title: "",
  561. open: false
  562. },
  563. // 表单校验
  564. rules: {
  565. name: [{ required: true, message: "名称不能为空", trigger: "submit" }],
  566. type: [{ required: true, message: "不能为空", trigger: "submit" }],
  567. sendType: [{ required: true, message: "不能为空", trigger: "submit" }],
  568. startTime: [{ required: true, message: "开始时间不能为空", trigger: "submit" }],
  569. tempId: [{ required: true, message: "模板不能为空", trigger: "submit" }],
  570. },
  571. autoSopTimeRules: {
  572. autoSopType: [{ required: true, message: "选项不能为空", trigger: "submit" }],
  573. autoStartTime: [{ required: true, message: "起始时间不能为空", trigger: "submit" }],
  574. autoEndTime: [{ required: true, message: "结束时间不能为空", trigger: "submit" }],
  575. autoDateTime: [{ required: true, message: "日期不能为空", trigger: "submit" }],
  576. }
  577. };
  578. },
  579. created() {
  580. this.init();
  581. },
  582. watch: {
  583. userSelectList(newList) {
  584. this.form.qwUserIds = newList.map(item => item.id);
  585. }
  586. },
  587. methods: {
  588. /**
  589. * 初始化加载
  590. */
  591. async init() {
  592. this.getDicts("app_sop_status").then(response => {
  593. this.sysSopStatus = response.data;
  594. });
  595. this.getDicts("app_sop_plugin_settingType").then(response => {
  596. this.sysQwSopAiContentType = response.data;
  597. });
  598. this.getDicts("app_sop_watch_status").then(response => {
  599. this.sysFsSopWatchStatus = response.data;
  600. });
  601. this.getDicts("app_normal_disabled_status").then(response => {
  602. this.statusOptions = response.data;
  603. });
  604. this.getDicts("app_sop_autoType").then(response => {
  605. this.autoSopTypeOptions = response.data;
  606. });
  607. this.getDicts("app_sop_type").then(response => {
  608. this.appSopType = response.data;
  609. });
  610. let cl = this.getCourseList(null);
  611. this.courseList = cl.list;
  612. this.getList();
  613. },
  614. /**
  615. * 获取科普列表
  616. * @param keyword
  617. */
  618. async getCourseList(keyword) {
  619. let query = {
  620. keyword: keyword,
  621. pageNum: 1,
  622. pageSize: 50,
  623. };
  624. return await courseList(query);
  625. },
  626. // 搜索的标签
  627. hangleChangeTags() {
  628. this.changeTagDialog.title = "搜索的标签"
  629. this.changeTagDialog.open = true;
  630. this.queryTagParams.name = null;
  631. this.getPageListTagGroup();
  632. },
  633. // 删除一些选择的标签
  634. handleCloseTags(list) {
  635. const ls = this.selectTags.findIndex(t => t.id === list.id);
  636. if (ls !== -1) {
  637. this.selectTags.splice(ls, 1);
  638. this.selectTags = [...this.selectTags];
  639. }
  640. if (this.selectTags != null && this.selectTags.length > 0) {
  641. // 确保 this.form.tags 是数组
  642. if (!this.queryParams.tagIds) {
  643. this.queryParams.tagIds = []; // 如果未定义,初始化
  644. } else {
  645. this.queryParams.tagIds = []; // 清空已有数据
  646. }
  647. // 遍历并添加 tagId
  648. this.selectTags.forEach(tag => {
  649. if (tag.id) { // 确保 tagId 存在
  650. this.queryParams.tagIds.push(tag.id);
  651. }
  652. });
  653. this.queryParams.tagIds = this.queryParams.tagIds.join(",");
  654. } else {
  655. this.queryParams.tagIds = null;
  656. }
  657. },
  658. // 选择/取消选择标签
  659. tagSelection(row) {
  660. row.isSelected = !row.isSelected;
  661. this.$forceUpdate();
  662. },
  663. // 确定选择标签
  664. tagSubmitForm() {
  665. for (let i = 0; i < this.tagGroupList.length; i++) {
  666. for (let x = 0; x < this.tagGroupList[i].tags.length; x++) {
  667. if (this.tagGroupList[i].tags[x].isSelected === true) {
  668. if (!this.selectTags) {
  669. this.selectTags = [];
  670. }
  671. // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
  672. let tagExists = this.selectTags.some(
  673. tag => tag.id === this.tagGroupList[i].tags[x].id
  674. );
  675. // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
  676. if (!tagExists) {
  677. this.selectTags.push(this.tagGroupList[i].tags[x]);
  678. }
  679. }
  680. }
  681. }
  682. if (!this.selectTags || this.selectTags.length === 0) {
  683. return this.$message('请选择标签');
  684. }
  685. this.changeTagDialog.open = false;
  686. },
  687. // 取消选择标签
  688. tagCancel() {
  689. this.changeTagDialog.open = false;
  690. },
  691. // 获取标签组列表
  692. getPageListTagGroup() {
  693. // this.queryTagParams.corpId = this.queryParams.corpId
  694. let qp = {...this.queryTagParams, groupName: this.queryTagParams.name}
  695. listTagGroupForUserBindTag(qp).then(response => {
  696. let rows = response.rows;
  697. this.tagGroupList = rows;
  698. this.tagTotal = response.total;
  699. });
  700. },
  701. // 搜索标签
  702. handleSearchTags(name) {
  703. this.getPageListTagGroup();
  704. },
  705. // 重置标签搜索
  706. cancelSearchTags() {
  707. this.resetSearchQueryTag()
  708. this.getPageListTagGroup();
  709. },
  710. // 重置标签查询参数
  711. resetSearchQueryTag() {
  712. this.queryTagParams = {
  713. pageNum: 1,
  714. pageSize: 10,
  715. total: 0,
  716. name: null,
  717. };
  718. },
  719. // 在组件销毁前保存当前选择
  720. beforeDestroy() {
  721. // if (this.queryParams.corpId) {
  722. // localStorage.setItem('selectedCorpId', this.queryParams.corpId);
  723. // }
  724. },
  725. getLuckyBagStatus(content) {
  726. const selectedLuckyBag = this.luckyBagList.find(item => item.id === content.luckyBagId);
  727. if (selectedLuckyBag) {
  728. content.luckyBagDataStatus = selectedLuckyBag.dataStatus; // 自动填充标题
  729. } else {
  730. // 若未找到对应直播间,清空标题和封面(可选)
  731. content.luckyBagDataStatus = null;
  732. }
  733. },
  734. checkLiveMiniprogramTitle(item) {
  735. this.$forceUpdate();
  736. },
  737. liveChange(content) {
  738. // content.liveId 是选中的直播间 ID(liveId)
  739. const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
  740. if (selectedLive) {
  741. // 从选中的直播间对象中提取标题和封面,赋值给当前内容的对应字段
  742. // 假设直播间对象中标题字段为 liveTitle,封面字段为 coverImg(根据实际接口字段调整)
  743. content.miniprogramTitle = selectedLive.liveName || ''; // 自动填充标题
  744. content.miniprogramPicUrl = selectedLive.liveImgUrl || ''; // 自动填充封面
  745. } else {
  746. // 若未找到对应直播间,清空标题和封面(可选)
  747. content.miniprogramTitle = '';
  748. content.miniprogramPicUrl = '';
  749. }
  750. },
  751. voice(id) {
  752. this.voiceForm.queryParams.id = id;
  753. getSopVoiceList(this.voiceForm.queryParams).then(res => {
  754. this.voiceForm.list = res.rows;
  755. this.voiceForm.total = res.total;
  756. this.voiceForm.open = true;
  757. })
  758. },
  759. // 单元格点击事件
  760. handleCellClick(row, column, cell, event) {
  761. // 判断是否为规则编号列
  762. if (column.property === 'id') {
  763. this.handleRowClick(row); // 触发规则编号点击事件
  764. }
  765. },
  766. // handleUpdateTags(){
  767. //
  768. // },
  769. // handleUpdateQwUser(){
  770. //
  771. // },
  772. // handleUpdateSopTemp(){
  773. //
  774. // },
  775. handleRowClick(row, column, event) {
  776. // 判断状态是否符合条件
  777. if (row.status == 2 || row.status == 0 || row.status == 3 || row.status == 4) {
  778. this.handleUpdate(row, 2);
  779. }
  780. },
  781. // 切换某一行的展开状态
  782. toggleRow(row) {
  783. this.$set(this.expandedRows, row.id, !this.expandedRows[row.id]);
  784. },
  785. getSwitchVal(status) {
  786. return [2, 3, 4].includes(status) ? 2 : 0;
  787. },
  788. onSwitchChange(row, val) {
  789. this.loading = true;
  790. // ① 调用接口更新后端
  791. updateSopStatus({ id: row.id, status: val })
  792. .then(() => {
  793. row.status = val;
  794. this.loading = false;
  795. this.$message.success("切换成功!");
  796. })
  797. .catch(() => {
  798. this.loading = false;
  799. this.$message.error("操作失败,请重试");
  800. });
  801. },
  802. switchSopStatusChange(row, checked) {
  803. let loadingRock = this.$loading({
  804. lock: true,
  805. text: '暂停中-请勿刷新页面-重复点击',
  806. spinner: 'el-icon-loading',
  807. background: 'rgba(0, 0, 0, 0.7)'
  808. });
  809. updateSopStatus({ id: row, status: checked }).then(response => {
  810. this.$message.success("修改成功");
  811. this.getList();
  812. }).finally(res => {
  813. loadingRock.close();
  814. })
  815. },
  816. /**
  817. * 新客户自动创建sop
  818. * @param row
  819. * @param checked
  820. */
  821. switchAutoSopChange(row, checked) {
  822. this.form.startTime = row.startTime;
  823. this.form.autoSopTime = JSON.parse(row.autoSopTime);
  824. if (checked == 1) {
  825. this.autoSopOpen.title = '请设置相应时间段'
  826. this.autoSopOpen.open = true;
  827. this.autoSopOpen.id = row.id;
  828. this.autoSopOpen.isAutoSop = 1;
  829. } else {
  830. this.form.autoSopTime.createTime = this.formatDateTo24HourString(new Date());
  831. updateAutoSopTime({
  832. id: row.id,
  833. isAutoSop: checked,
  834. autoSopTime: JSON.stringify(this.form.autoSopTime)
  835. }).then(response => {
  836. this.getList();
  837. })
  838. }
  839. },
  840. updateCorpId() {
  841. if (this.queryParams.corpId) {
  842. localStorage.setItem('selectedCorpId', this.queryParams.corpId);
  843. }
  844. this.reset();
  845. this.refreshData(this.queryParams.corpId);
  846. this.queryParams.qwUserId = null;
  847. this.getList();
  848. },
  849. //刷新部分数据
  850. refreshData(row) {
  851. // getQwAllUserList(row).then(response => {
  852. // this.companyUserList = response.data;
  853. // });
  854. // listTag({corpId: row}).then(response => {
  855. // this.tagList = response.rows;
  856. // });
  857. if (row != null) {
  858. // allList(row).then(e => {
  859. // this.chatList = e.data;
  860. // })
  861. }
  862. },
  863. //查询模板
  864. selectListSopTemp(type) {
  865. this.tempListLoading = true; // 开始查询,显示加载提示
  866. listSopTemp({ sendType: type }).then(response => {
  867. this.tempList = response.rows;
  868. this.tempListLoading = false;
  869. });
  870. },
  871. handlelistUser(type, sendType) {
  872. setTimeout(() => {
  873. this.$refs.QwUserList.getDetails(this.queryParams.corpId, type, sendType);
  874. }, 1);
  875. this.listUser.title = "选择企业成员"
  876. this.listUser.open = true;
  877. },
  878. selectUserList(list) {
  879. this.listUser.open = false;
  880. list.forEach(obj => {
  881. if (!this.userSelectList.some(item => item == obj.id)) {
  882. this.userSelectList.push(obj.id);
  883. }
  884. });
  885. },
  886. //修改过期时间
  887. handleUpdateTemp(val) {
  888. this.tempUser.updateOpen = true;
  889. this.tempUser.form = {
  890. id: val.id,
  891. qwId: val.qwId,
  892. liveTempId: val.tempId,
  893. liveTempSendTime: val.sendTime,
  894. }
  895. },
  896. //修改过期时间
  897. submitTemp() {
  898. if (this.tempUser.form.liveTempId == null) {
  899. return this.$message.error("请选择直播模板")
  900. }
  901. if (this.tempUser.form.liveTempSendTime == null) {
  902. return this.$message.error("请选择发送时间")
  903. }
  904. updateTemp({ id: this.tempUser.form.id, sopId: this.tempUser.id, tempId: this.tempUser.form.liveTempId, sendTime: this.tempUser.form.liveTempSendTime, qwId: this.tempUser.form.qwId }).then(response => {
  905. this.msgSuccess("修改成功");
  906. this.tempUser.updateOpen = false;
  907. this.listTemp();
  908. });
  909. },
  910. handleUpdateOutTime(val) {
  911. this.outTimeOpen.title = "修改过期时间/评级";
  912. this.outTimeOpen.id = val.id;
  913. this.outTimeOpen.tempId = val.tempId;
  914. this.outTimeOpen.expiryTime = val.expiryTime;
  915. this.outTimeOpen.isRating = val.isRating;
  916. this.outTimeOpen.minConversionDay = val.minConversionDay;
  917. this.outTimeOpen.maxConversionDay = val.maxConversionDay;
  918. this.outTimeOpen.courseDay = val.courseDay;
  919. this.outTimeOpen.isSampSend = val.isSampSend;
  920. this.outTimeOpen.isLiveMgs = val.isLiveMgs;
  921. this.outTimeOpen.liveTempId = val.liveTempId;
  922. this.outTimeOpen.liveTempSendTime = val.liveTempSendTime;
  923. this.outTimeOpen.appId = val.appId;
  924. this.outTimeOpen.open = true;
  925. },
  926. handleUpdateExpiryTime() {
  927. updateSop({
  928. id: this.outTimeOpen.id,
  929. tempId: this.outTimeOpen.tempId,
  930. expiryTime: this.outTimeOpen.expiryTime,
  931. isRating: this.outTimeOpen.isRating,
  932. minConversionDay: this.outTimeOpen.minConversionDay,
  933. maxConversionDay: this.outTimeOpen.maxConversionDay,
  934. courseDay: this.outTimeOpen.courseDay,
  935. isLiveMgs: this.outTimeOpen.isLiveMgs,
  936. liveTempId: this.outTimeOpen.liveTempId,
  937. liveTempSendTime: this.outTimeOpen.liveTempSendTime,
  938. isSampSend: this.outTimeOpen.isSampSend,
  939. appId: this.outTimeOpen.appId,
  940. }).then(response => {
  941. this.msgSuccess("修改成功");
  942. this.resetUpdateExpiryTime()
  943. this.getList();
  944. });
  945. },
  946. resetUpdateExpiryTime() {
  947. this.outTimeOpen = {
  948. title: '',
  949. open: false,
  950. id: null,
  951. expiryTime: null,
  952. courseDay: null,
  953. isLiveMgs: 0,
  954. liveTempId: null,
  955. liveTempSendTime: null,
  956. minConversionDay: null,
  957. maxConversionDay: null,
  958. isRating: null,
  959. isSampSend: null,
  960. appId: null
  961. }
  962. },
  963. addContent(index) {
  964. // this.setting[index].content.push({type:1})
  965. if (this.form.sendType == 2) {
  966. this.setting[index].content.push({ type: 1 });
  967. } else {
  968. if (this.setting[index].content.length < 9) {
  969. this.setting[index].content.push({ type: 1 });
  970. } else {
  971. this.$message({
  972. message: '最多只能添加 9 个内容',
  973. type: 'warning'
  974. });
  975. }
  976. }
  977. },
  978. //选择变动时的变动
  979. handleSendTypeChange(val) {
  980. this.tempList = [];
  981. this.form.tempId = null;
  982. if (val == 1) {
  983. // 遍历 this.setting 数组并清空每个对象的 content 属性
  984. this.setting.forEach(item => {
  985. if (item.content.length > 9) {
  986. item.content = item.content.slice(0, 9); // 保留前 9 个元素
  987. }
  988. });
  989. }
  990. },
  991. delContent(index, contentIndex) {
  992. this.setting[index].content.splice(contentIndex, 1)
  993. },
  994. //添加SOP规则类型
  995. handleCommand(command) {
  996. this.setting.push({
  997. sopType: command,
  998. ruleType: null,
  999. name: null,
  1000. type: 1,
  1001. content: [],
  1002. isBindUrl: 1,
  1003. url: null,
  1004. day: "0",
  1005. hour: "0",
  1006. minute: "0",
  1007. time: ""
  1008. })
  1009. },
  1010. //添加科普SOP
  1011. handleCrouseCommand(command, val) {
  1012. console.log("command", command)
  1013. console.log("val", val)
  1014. },
  1015. delSetting(index) {
  1016. this.setting.splice(index, 1)
  1017. },
  1018. handleClosegroupUser(list) {
  1019. const index = this.userSelectList.findIndex(t => t === list);
  1020. if (index !== -1) {
  1021. this.userSelectList.splice(index, 1);
  1022. }
  1023. },
  1024. /**
  1025. * 查询sop列表
  1026. */
  1027. getList() {
  1028. this.loading = true;
  1029. listSop(this.queryParams).then(response => {
  1030. this.sopList = response.rows;
  1031. this.total = response.total;
  1032. this.loading = false;
  1033. listSopTemp().then(res => {
  1034. this.tempList = res.rows;
  1035. });
  1036. });
  1037. },
  1038. // 取消按钮
  1039. cancel() {
  1040. this.open = false;
  1041. this.reset();
  1042. },
  1043. // 表单重置
  1044. reset() {
  1045. this.form = {
  1046. id: null,
  1047. name: null,
  1048. status: 1,
  1049. sendType: 2,
  1050. type: 2,
  1051. filterType: 2,
  1052. isLiveMgs: 0,
  1053. qwUserIds: null,
  1054. liveTempId: null,
  1055. liveTempSendTime: null,
  1056. corpId: null,
  1057. setting: null,
  1058. createBy: null,
  1059. createTime: null,
  1060. isAutoSop: null,
  1061. autoSopTime: { autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2, autoDateTime: [] },
  1062. };
  1063. this.resetForm("form");
  1064. this.tags = null;
  1065. this.excludeTags = null;
  1066. },
  1067. /** 搜索按钮操作 */
  1068. handleQuery() {
  1069. // 处理标签ID参数
  1070. if (this.selectTags != null && this.selectTags.length > 0) {
  1071. this.queryParams.tagIds = this.selectTags.map(tag => tag.id).join(",");
  1072. } else {
  1073. this.queryParams.tagIds = null;
  1074. }
  1075. this.queryParams.pageNum = 1;
  1076. this.getList();
  1077. },
  1078. /** 重置按钮操作 */
  1079. resetQuery() {
  1080. this.resetForm("queryForm");
  1081. // this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
  1082. this.selectTags = null;
  1083. this.refreshData(this.queryParams.corpId);
  1084. this.handleQuery();
  1085. },
  1086. // 多选框选中数据
  1087. handleSelectionChange(selection) {
  1088. this.ids = selection.map(item => item.id)
  1089. this.selectionMap = selection;
  1090. this.single = selection.length !== 1
  1091. this.multiple = !selection.length
  1092. },
  1093. // 新增按钮操作
  1094. handleAdd() {
  1095. this.reset();
  1096. this.$router.push('/app/sop/addSop')
  1097. },
  1098. /** 修改按钮操作 */
  1099. handleUpdate(row, type) {
  1100. this.$router.push('/app/sop/updateSop/' + row.id + '/' + type)
  1101. },
  1102. handleTemp(id) {
  1103. this.tempUser.open = true;
  1104. this.tempUser.id = id;
  1105. this.listTemp();
  1106. },
  1107. listTemp() {
  1108. this.tempUser.loading = true;
  1109. getTempUserList(this.tempUser.id).then(e => {
  1110. this.tempUser.list = e.data;
  1111. this.tempUser.loading = false;
  1112. })
  1113. },
  1114. /**
  1115. * 查看SOP任务内营期
  1116. */
  1117. selectSchedule(row) {
  1118. // type 2:我的sop 1:部门sop/客服公司sop
  1119. const query = {
  1120. id: row.id,
  1121. name: row.name,
  1122. tempId: row.tempId,
  1123. filterMode: row.filterMode,
  1124. // corpId: row.corpId,
  1125. type: 1,
  1126. }
  1127. // 使用 params 传递参数
  1128. this.$router.push({
  1129. path: `/app/sop/sopUserLogsSchedule/${query.id}`,
  1130. query // 如果需要传递更多参数,可以使用 query
  1131. });
  1132. },
  1133. /**
  1134. * 查看营期内详情
  1135. */
  1136. handleScheduleDetail(row) {
  1137. this.sopLogsDialog.title = '规则执行详情7';
  1138. this.sopLogsDialog.open = true;
  1139. this.sopLogsDialog.sopLogsForm = row;
  1140. // 使用Vue.set或this.$set添加新字段
  1141. this.$set(this.sopLogsDialog.sopLogsForm, 'filterSopType', 1);
  1142. },
  1143. /**
  1144. * 查看模板
  1145. */
  1146. handleQueryDetails(row) {
  1147. this.$router.push(`/user/sopTemp/updateSopTemp/${row.tempId}/3`)
  1148. },
  1149. /** 提交按钮 */
  1150. submitForm() {
  1151. this.$refs["form"].validate(valid => {
  1152. if (valid) {
  1153. if (this.userSelectList.length <= 0) {
  1154. return this.$message("请选择员工")
  1155. }
  1156. this.form.qwUserIds = this.userSelectList.join(",");
  1157. if (this.tags != null && this.tags.length > 0) {
  1158. this.form.tags = (this.tags).toString()
  1159. } else {
  1160. return this.$message.error("选择的标签不能为空!!请选择筛选的标签")
  1161. }
  1162. if (this.excludeTags != null) {
  1163. this.form.excludeTags = (this.excludeTags).toString()
  1164. }
  1165. this.form.setting = JSON.stringify(this.setting)
  1166. if (this.form.id != null) {
  1167. updateSop(this.form).then(response => {
  1168. this.msgSuccess("修改成功");
  1169. this.open = false;
  1170. this.getList();
  1171. });
  1172. } else {
  1173. addSop(this.form).then(response => {
  1174. this.msgSuccess("新增成功");
  1175. this.open = false;
  1176. this.getList();
  1177. });
  1178. }
  1179. }
  1180. });
  1181. },
  1182. sortSelectedDates(dates) {
  1183. if (!this.form.startTime) {
  1184. this.$message.error("请先选择开始时间!不得小于任务开始时间");
  1185. this.form.autoSopTime.autoDateTime = [];
  1186. return;
  1187. }
  1188. // 1. 过滤掉 < startTime 的日期
  1189. const validDates = dates.filter(date => new Date(date) >= new Date(this.form.startTime));
  1190. // 2. 如果有被过滤掉的日期,提示用户
  1191. if (validDates.length < dates.length) {
  1192. this.$message.warning(`已自动移除小于 ${this.form.startTime} 的日期!`);
  1193. }
  1194. // 3. 升序排序
  1195. validDates.sort((a, b) => new Date(a) - new Date(b));
  1196. // 4. 更新数据
  1197. this.form.autoSopTime.autoDateTime = validDates;
  1198. },
  1199. submitAutoSopTimeFrom() {
  1200. if (this.form.autoSopTime.autoSopType == 3 || this.form.autoSopTime.autoSopType == 4) {
  1201. if (this.form.autoSopTime.autoDateTime == null || this.form.autoSopTime.autoDateTime == "") {
  1202. return this.$message.error("选择的日期不能为空!!请选择日期")
  1203. }
  1204. }
  1205. this.$refs["autoSopTimeFrom"].validate(valid => {
  1206. if (valid) {
  1207. this.autoSopOpen.open = false
  1208. this.form.autoSopTime.createTime = this.formatDateTo24HourString(new Date());
  1209. updateAutoSopTime({
  1210. id: this.autoSopOpen.id,
  1211. isAutoSop: this.autoSopOpen.isAutoSop,
  1212. autoSopTime: JSON.stringify(this.form.autoSopTime)
  1213. }).then(response => {
  1214. this.msgSuccess("修改成功");
  1215. });
  1216. }
  1217. this.getList();
  1218. this.reset();
  1219. });
  1220. },
  1221. formatDateTo24HourString(date) {
  1222. let year = date.getFullYear();
  1223. let month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份需要加 1 并补零
  1224. let day = ('0' + date.getDate()).slice(-2); // 日需要补零
  1225. let hours = ('0' + date.getHours()).slice(-2); // 小时需要补零
  1226. let minutes = ('0' + date.getMinutes()).slice(-2); // 分钟需要补零
  1227. let seconds = ('0' + date.getSeconds()).slice(-2); // 秒需要补零
  1228. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  1229. },
  1230. cancelAutoSopTime() {
  1231. this.autoSopOpen.open = false
  1232. this.getList();
  1233. },
  1234. /** 删除按钮操作 */
  1235. handleDelete(row) {
  1236. const ids = row.id || this.ids;
  1237. this.$confirm('是否确认删除企微自动化编号为"' + ids + '"的数据项?', "警告", {
  1238. confirmButtonText: "确定",
  1239. cancelButtonText: "取消",
  1240. type: "warning"
  1241. }).then(function () {
  1242. return delSop(ids);
  1243. }).then(() => {
  1244. this.getList();
  1245. this.msgSuccess("删除成功");
  1246. }).catch(() => {
  1247. });
  1248. },
  1249. /**
  1250. * 批量执行SOP任务
  1251. */
  1252. handleExecute() {
  1253. const ids = this.selectionMap
  1254. .filter(item => item.status === 1)
  1255. .map(item => item.id);
  1256. if (ids.length === 0) {
  1257. this.msgError("选择的任务已经执行或正在执行,请选择待执行的任务");
  1258. return;
  1259. }
  1260. this.$confirm('是否确认立即执行自动化编号为"' + ids + '"的数据项?', "警告【只能立即执行(待执行的)】", {
  1261. confirmButtonText: "确定",
  1262. cancelButtonText: "取消",
  1263. type: "warning"
  1264. }).then(() => {
  1265. this.loading = true;
  1266. // 执行更新操作
  1267. return updateStatus(ids); // 返回一个Promise,直接在此链式调用
  1268. }).then(res => {
  1269. let msg = "";
  1270. // 判断成功和失败的任务,并显示消息
  1271. if (res.suc.length > 0) {
  1272. msg += "执行成功的自动化任务【" + res.suc.join(", ") + "】。<br>"; // 优化:将数组转换为字符串
  1273. }
  1274. if (res.err.length > 0) {
  1275. msg += "失败的自动化任务【" + res.err.join(", ") + "】,原因是已经执行或正在执行。<br>";
  1276. }
  1277. // 显示确认框,显示成功与失败信息
  1278. return this.$confirm(msg, "提示", {
  1279. confirmButtonText: "确定",
  1280. cancelButtonText: "取消",
  1281. type: "warning",
  1282. dangerouslyUseHTMLString: true // 允许HTML标签
  1283. });
  1284. }).then(() => {
  1285. // 操作完成后刷新列表,并显示成功信息
  1286. this.getList();
  1287. this.msgSuccess("执行完成");
  1288. }).catch(() => {
  1289. // 处理任何异常,操作取消或者失败时显示提示信息
  1290. this.msgError("操作失败,请重试");
  1291. }).finally(() => {
  1292. this.loading = false; // 操作完成后关闭加载状态
  1293. });
  1294. },
  1295. /** 导出按钮操作 */
  1296. handleExport() {
  1297. const queryParams = this.queryParams;
  1298. this.$confirm('是否确认导出所有企微自动化数据项?', "警告", {
  1299. confirmButtonText: "确定",
  1300. cancelButtonText: "取消",
  1301. type: "warning"
  1302. }).then(() => {
  1303. this.exportLoading = true;
  1304. return exportSop(queryParams);
  1305. }).then(response => {
  1306. this.download(response.msg);
  1307. this.exportLoading = false;
  1308. }).catch(() => {
  1309. });
  1310. },
  1311. courseChange() {
  1312. if (this.msgForm.courseId != null) {
  1313. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  1314. for (let i = 0; i < this.setting.length; i++) {
  1315. //响应式直接给链接的标题/封面上值
  1316. if (selectedCourse && this.setting[i].contentType == 3 && this.msgForm.courseId != null) {
  1317. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1318. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1319. }
  1320. }
  1321. }
  1322. videoList(this.msgForm.courseId).then(response => {
  1323. this.videoList = response.list;
  1324. });
  1325. },
  1326. handleContentTypeChange() {
  1327. //如果是链接的才上
  1328. if (this.msgForm.courseId != null) {
  1329. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  1330. for (let i = 0; i < this.setting.length; i++) {
  1331. //响应式直接给链接的标题/封面上值
  1332. if (selectedCourse && this.msgForm.courseId != null) {
  1333. console.log(1, this.setting[i].contentType)
  1334. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9) {
  1335. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1336. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1337. }
  1338. if (this.setting[i].contentType == 4) {
  1339. this.$set(this.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  1340. }
  1341. }
  1342. }
  1343. }
  1344. if (this.msgForm.videoId != null) {
  1345. // 查找选中的课节对应的 label
  1346. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  1347. for (let i = 0; i < this.setting.length; i++) {
  1348. //响应式直接给链接的描述上值
  1349. if (selectedVideo && this.msgForm.videoId != null) {
  1350. console.log(2, this.setting[i].contentType)
  1351. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9) {
  1352. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1353. }
  1354. if (this.setting[i].contentType == 4) {
  1355. this.$set(this.setting[i], 'miniprogramTitle', selectedVideo.dictLabel);
  1356. }
  1357. }
  1358. }
  1359. }
  1360. },
  1361. handleAvatarSuccessFile(res, file, item) {
  1362. if (res.code === 200) {
  1363. // 使用 $set 确保响应式更新
  1364. this.$set(item, 'fileUrl', res.url);
  1365. } else {
  1366. this.msgError(res.msg);
  1367. }
  1368. },
  1369. beforeAvatarUploadFile(file) {
  1370. const isLt1M = file.size / 1024 / 1024 < 10;
  1371. if (!isLt1M) {
  1372. this.$message.error('上传大小不能超过 10MB!');
  1373. }
  1374. return isLt1M;
  1375. },
  1376. //下载文件
  1377. downloadUrl(materialUrl) {
  1378. // 直接返回文件 URL
  1379. return materialUrl;
  1380. },
  1381. handleAvatarSuccessVideo(res, file, item) {
  1382. if (res.code == 200) {
  1383. // 使用 $set 确保响应式更新
  1384. this.$set(item, 'videoUrl', res.url);
  1385. } else {
  1386. this.msgError(res.msg);
  1387. }
  1388. },
  1389. beforeAvatarUploadVideo(file) {
  1390. const isLt30M = file.size / 1024 / 1024 < 10;
  1391. const isMP4 = file.type === 'video/mp4';
  1392. if (!isMP4) {
  1393. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  1394. return false;
  1395. }
  1396. if (!isLt30M) {
  1397. this.$message.error('上传大小不能超过 10MB!');
  1398. return false;
  1399. }
  1400. return true;
  1401. },
  1402. handleInputVideoText(value, content) {
  1403. // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
  1404. const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
  1405. // 删除不符合条件的字符
  1406. const filteredValue = value.split('').filter(char => regex.test(char)).join('');
  1407. this.$set(content, 'value', filteredValue);
  1408. },
  1409. delSetList(index) {
  1410. this.setting.splice(index, 1)
  1411. },
  1412. addSetList() {
  1413. const newSetting = {
  1414. contentType: '1',
  1415. value: '',
  1416. };
  1417. // 将新设置项添加到 content.setting 数组中
  1418. this.setting.push(newSetting);
  1419. },
  1420. isEmpty(obj) {
  1421. if (null === obj || undefined === obj || 0 === obj.length) {
  1422. return true;
  1423. }
  1424. return false;
  1425. },
  1426. videoIdChange() {
  1427. if (this.msgForm.videoId != null) {
  1428. // 查找选中的课节对应的 label
  1429. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  1430. for (let i = 0; i < this.setting.length; i++) {
  1431. //响应式直接给链接的描述上值
  1432. if (selectedVideo && this.msgForm.videoId != null) {
  1433. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9) {
  1434. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1435. }
  1436. if (this.setting[i].contentType == 4) {
  1437. this.$set(this.setting[i], 'miniprogramTitle', selectedVideo.dictLabel);
  1438. }
  1439. }
  1440. }
  1441. }
  1442. },
  1443. }
  1444. }
  1445. ;
  1446. </script>
  1447. <style scoped>
  1448. .custom-input ::v-deep .el-input__inner {
  1449. height: 20px;
  1450. padding: 0 4px;
  1451. text-align: center;
  1452. display: block;
  1453. }
  1454. .custom-input ::v-deep .el-input__icon {
  1455. line-height: 20px;
  1456. }
  1457. .el-button--text {
  1458. cursor: pointer;
  1459. }
  1460. /* CSS 样式 */
  1461. .tag-container {
  1462. display: flex;
  1463. flex-wrap: wrap; /* 超出宽度时自动换行 */
  1464. gap: 8px; /* 设置标签之间的间距 */
  1465. }
  1466. .name-background {
  1467. display: inline-block;
  1468. background-color: #abece6; /* 背景颜色 */
  1469. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  1470. border-radius: 4px; /* 可选:设置圆角 */
  1471. }
  1472. .tag-box {
  1473. padding: 8px 12px;
  1474. border: 1px solid #989797;
  1475. border-radius: 4px;
  1476. cursor: pointer;
  1477. display: inline-block;
  1478. }
  1479. .tag-selected {
  1480. background-color: #00bc98;
  1481. color: #fff;
  1482. border-color: #00bc98;
  1483. }
  1484. </style>