sop.vue 63 KB

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