sop.vue 63 KB

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