sop.vue 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
  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"
  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-select v-model="msgForm.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange()">
  606. <el-option
  607. v-for="dict in courseList"
  608. :key="dict.dictValue"
  609. :label="dict.dictLabel"
  610. :value="parseInt(dict.dictValue)"
  611. />
  612. </el-select>
  613. <el-select v-model="msgForm.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange()" >
  614. <el-option
  615. v-for="dict in videoList"
  616. :key="dict.dictValue"
  617. :label="dict.dictLabel"
  618. :value="parseInt(dict.dictValue)"
  619. />
  620. </el-select>
  621. <el-select v-model="msgForm.courseType" placeholder="请选择消息类型" size="mini" style=" margin-right: 10px;">
  622. <el-option
  623. v-for="dict in sysFsSopWatchStatus"
  624. :key="dict.dictValue"
  625. :label="dict.dictLabel"
  626. :value="parseInt(dict.dictValue)"
  627. />
  628. </el-select>
  629. </el-form-item>
  630. <el-form-item label="规则" prop="setting" >
  631. <div v-for="(item, index) in setting" :key="index" style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  632. <el-row>
  633. <el-col :span="22">
  634. <el-form :model="item" label-width="70px">
  635. <el-form-item label="内容类别" style="margin: 2%">
  636. <el-radio-group v-model="item.contentType">
  637. <el-radio :label="item.dictValue" v-for="item in sysQwSopAiContentType" @change="handleContentTypeChange()">{{item.dictLabel}}</el-radio>
  638. </el-radio-group>
  639. </el-form-item>
  640. <el-form-item label="内容" style="margin-bottom: 2%" >
  641. <el-input v-if="item.contentType == 1 " v-model="item.value" type="textarea" :rows="3" placeholder="内容" style="width: 90%;margin-top: 10px;"/>
  642. <ImageUpload v-if="item.contentType == 2 " v-model="item.imgUrl" type="image" :num="1" :width="150" :height="150" />
  643. <div v-if="item.contentType == 3 ">
  644. <el-card class="box-card">
  645. <el-form-item label="链接标题:" label-width="100px">
  646. <el-input v-model="item.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  647. </el-form-item>
  648. <el-form-item label="链接描述:" label-width="100px" >
  649. <el-input type="textarea" :rows="3" v-model="item.linkDescribe" placeholder="请输入链接描述" style="width: 90%;margin-top: 1%;"/>
  650. </el-form-item>
  651. <el-form-item label="链接封面:" label-width="100px">
  652. <ImageUpload v-model="item.linkImageUrl" type="image" :num="1" :file-size="2" :width="150" :height="150" style="margin-top: 1%;" />
  653. </el-form-item>
  654. <el-form-item label="链接地址:" label-width="100px" >
  655. <el-tag type="warning" v-model="item.isBindUrl=1">选择的课程小节 即为卡片链接地址</el-tag>
  656. </el-form-item>
  657. </el-card>
  658. </div>
  659. <div v-if="item.contentType == 4">
  660. </div>
  661. <div v-if="item.contentType == 5 ">
  662. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  663. <el-upload
  664. v-model="item.fileUrl"
  665. class="avatar-uploader"
  666. :action="uploadUrl"
  667. :show-file-list="false"
  668. :on-success="(res, file) => handleAvatarSuccessFile(res, file, item)"
  669. :before-upload="beforeAvatarUploadFile">
  670. <i class="el-icon-plus avatar-uploader-icon"></i>
  671. </el-upload>
  672. <el-link v-if="item.fileUrl" type="primary" :href="downloadUrl(item.fileUrl)" download>
  673. {{item.fileUrl}}
  674. </el-link>
  675. </el-form-item>
  676. </div>
  677. <div v-if="item.contentType == 6 ">
  678. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  679. <el-upload
  680. v-model="item.videoUrl"
  681. class="avatar-uploader"
  682. :action="uploadUrl"
  683. :show-file-list="false"
  684. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, item)"
  685. :before-upload="beforeAvatarUploadVideo">
  686. <i class="el-icon-plus avatar-uploader-icon"></i>
  687. </el-upload>
  688. <video v-if="item.videoUrl"
  689. :src="item.videoUrl"
  690. controls style="width: 200px;height: 100px">
  691. </video>
  692. </el-form-item>
  693. </div>
  694. <div v-if="item.contentType == 7 ">
  695. <el-input
  696. v-model="item.value"
  697. type="textarea" :rows="3" maxlength="66" show-word-limit
  698. placeholder="输入要转为语音的内容" style="width: 90%;margin-top: 10px;"
  699. @input="handleInputVideoText(item.value,item)"/>
  700. </div>
  701. <div v-if="item.contentType == 10 ">
  702. <el-card class="box-card">
  703. <el-form-item label="链接标题:" label-width="100px">
  704. <el-input v-model="item.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  705. </el-form-item>
  706. <el-form-item label="链接描述:" label-width="100px" >
  707. <el-input type="textarea" :rows="3" v-model="item.linkDescribe" placeholder="请输入链接描述" style="width: 90%;margin-top: 1%;"/>
  708. </el-form-item>
  709. <el-form-item label="链接封面:" label-width="100px">
  710. <ImageUpload v-model="item.linkImageUrl" type="image" :num="1" :file-size="2" :width="150" :height="150" style="margin-top: 1%;" />
  711. </el-form-item>
  712. <el-form-item label="链接地址:" label-width="100px" >
  713. <el-tag type="warning" >链接地址自动生成</el-tag>
  714. </el-form-item>
  715. </el-card>
  716. </div>
  717. </el-form-item>
  718. <el-form-item label="添加短链" v-if="item.contentType == 1 " >
  719. <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark" :disabled="!!msgForm.videoId">
  720. <el-switch
  721. v-model="item.isBindUrl"
  722. :disabled="!msgForm.videoId"
  723. active-color="#13ce66"
  724. inactive-color="#DCDFE6"
  725. active-value="1"
  726. inactive-value="2">
  727. </el-switch>
  728. </el-tooltip>
  729. <span v-if="item.isBindUrl == '1'" style="margin-left: 10px; color: #13ce66">添加URL</span>
  730. <span v-if="item.isBindUrl == '2'" style="margin-left: 10px; color: #b1b4ba">不加URL</span>
  731. </el-form-item>
  732. <el-form-item label="课节过期时间" v-if="item.isBindUrl == '1'
  733. && item.contentType != 2
  734. && item.contentType != 5
  735. && item.contentType != 6
  736. && item.contentType != 8
  737. && item.contentType != 9
  738. && item.contentType != 10"
  739. style="margin-top: 1%" label-width="100px">
  740. <el-row>
  741. <el-input-number v-model="item.expiresDays" :min="1" :max="100" ></el-input-number>
  742. (天)
  743. </el-row>
  744. <el-row>
  745. <span class="tip">填写0或不填时,默认为系统配置的默认时间</span>
  746. </el-row>
  747. </el-form-item>
  748. </el-form>
  749. </el-col>
  750. <el-col :span="1" :offset="1">
  751. <i class="el-icon-delete" @click="delSetList(index)" style="margin-top: 20px;" v-if="setting.length>1"></i>
  752. </el-col>
  753. </el-row>
  754. </div>
  755. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetList()' >添加内容</el-link>
  756. </el-form-item>
  757. </el-form>
  758. <div slot="footer" class="dialog-footer">
  759. <el-button type="primary" @click="submitMsgForm">确 定</el-button>
  760. <el-button @click="cancelMsgForm">取 消</el-button>
  761. </div>
  762. </el-dialog>
  763. </div>
  764. </template>
  765. <script>
  766. import {
  767. addSop,
  768. courseList,
  769. delSop,
  770. exportSop,
  771. getSopVoiceList,
  772. listSop,
  773. updateAutoSopTime,
  774. updateSop,
  775. updateSopStatus,
  776. updateStatus,
  777. videoList
  778. } from "@/api/qw/sop";
  779. import {sendMsgSop} from "@/api/qw/sopUserLogsInfo";
  780. import {listSopTemp} from "@/api/qw/sopTemp";
  781. import {getQwAllUserList, listUser} from '@/api/company/companyUser'
  782. import qwUserList from '@/views/qw/user/qwUserList.vue'
  783. import ImageUpload from "@/views/qw/sop/ImageUpload";
  784. import CustomerGroupDetails from '@/views/qw/groupMsg/customerGroupDetails.vue'
  785. import sopLogsDetails from '@/views/qw/sopLogs/sopLogsList.vue'
  786. import {listTag,} from "@/api/qw/tag";
  787. import {getMyQwCompanyList} from "@/api/qw/user";
  788. import {allList} from "@/api/qw/groupChat";
  789. export default {
  790. name: "Sop",
  791. components: {CustomerGroupDetails, qwUserList, ImageUpload, sopLogsDetails},
  792. data() {
  793. return {
  794. // 存储每一行的展开状态
  795. expandedRows: {},
  796. //模板查询
  797. tempListLoading: false,
  798. voiceLoading :false,
  799. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  800. uploadUrlByVoice:process.env.VUE_APP_BASE_API+"/common/uploadOSSByHOOKVoice",
  801. // 遮罩层
  802. loading: false,
  803. // 导出遮罩层
  804. exportLoading: false,
  805. videoList:[],
  806. // 选中数组
  807. ids: [],
  808. //选中的map
  809. selectionMap: {},
  810. myQwCompanyList: [],
  811. //销售员工列表
  812. companyUserLists: [],
  813. chatList: [],
  814. courseList: [],
  815. sendMsgOpen:{
  816. title:'一键批量群发',
  817. open:false,
  818. row: {},
  819. ids:null,
  820. },
  821. // videoList:[],
  822. tags: null,
  823. excludeTags: null,
  824. // 非单个禁用
  825. single: true,
  826. setting: [],
  827. tagList: [],
  828. tempList: [],
  829. // 非多个禁用
  830. multiple: true,
  831. // 显示搜索条件
  832. showSearch: true,
  833. // 总条数
  834. total: 0,
  835. msgForm:{
  836. videoId:null,
  837. courseId:null,
  838. courseType:null,
  839. userIdParam:null,
  840. setting:null,
  841. ids:null,
  842. sopId: null,
  843. startTime: null,
  844. chatIds: [],
  845. isRegister:2
  846. },
  847. // 企微sop表格数据
  848. sopList: [],
  849. // 弹出层标题
  850. title: "",
  851. // 是否显示弹出层
  852. open: false,
  853. companyUserList: [],
  854. // 状态字典
  855. statusOptions: [],
  856. //sop状态
  857. sysSopStatus: [],
  858. autoSopOpen: {
  859. title: '',
  860. open: false,
  861. id: null,
  862. isAutoSop: null,
  863. },
  864. outTimeOpen: {
  865. title: '',
  866. open: false,
  867. id: null,
  868. tempId: null,
  869. expiryTime: null,
  870. isRating: null,
  871. },
  872. voiceForm: {
  873. list: [],
  874. open: false,
  875. total: 0,
  876. queryParams: {
  877. pageNum: 1,
  878. pageSize: 10,
  879. id: null,
  880. },
  881. },
  882. //企微SOP发送类型
  883. sysQwSopType: [],
  884. sysQwSopAiContentType: [],
  885. //SOP课程观看状态
  886. sysFsSopWatchStatus: [],
  887. // 查询参数
  888. queryParams: {
  889. pageNum: 1,
  890. pageSize: 10,
  891. id: null,
  892. name: null,
  893. status: null,
  894. sendType: null,
  895. type: null,
  896. qwUserIds: null,
  897. setting: null,
  898. createBy: null,
  899. corpId: null,
  900. createTime: null
  901. },
  902. sopLogsDialog: {
  903. title: '',
  904. open: false,
  905. sopLogsForm: [],
  906. },
  907. // 表单参数
  908. form: {
  909. autoSopTime: {autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2},
  910. },
  911. userSelectList: [],
  912. listUser: {
  913. title: "",
  914. open: false
  915. },
  916. msgRules:{},
  917. // 表单校验
  918. rules: {
  919. name: [{required: true, message: "名称不能为空", trigger: "submit"}],
  920. type: [{required: true, message: "不能为空", trigger: "submit"}],
  921. sendType: [{required: true, message: "不能为空", trigger: "submit"}],
  922. startTime: [{required: true, message: "开始时间不能为空", trigger: "submit"}],
  923. tempId: [{required: true, message: "模板不能为空", trigger: "submit"}],
  924. },
  925. autoSopTimeRules: {
  926. autoSopType: [{required: true, message: "选项不能为空", trigger: "submit"}],
  927. autoStartTime: [{required: true, message: "起始时间不能为空", trigger: "submit"}],
  928. autoEndTime: [{required: true, message: "结束时间不能为空", trigger: "submit"}],
  929. }
  930. };
  931. },
  932. created() {
  933. this.getDicts("sys_sop_status").then(response => {
  934. this.sysSopStatus = response.data;
  935. });
  936. getMyQwCompanyList().then(response => {
  937. this.myQwCompanyList = response.data;
  938. if (this.myQwCompanyList != null) {
  939. allList(this.myQwCompanyList[0].dictValue).then(e => {
  940. this.chatList = e.data;
  941. })
  942. }
  943. });
  944. this.getDicts("sys_company_status").then(response => {
  945. this.statusOptions = response.data;
  946. });
  947. this.getDicts("sys_qw_sop_type").then(response => {
  948. this.sysQwSopType = response.data;
  949. });
  950. this.getDicts("sys_qwSopAi_contentType").then(response => {
  951. this.sysQwSopAiContentType = response.data;
  952. });
  953. this.getDicts("sys_fs_sop_watch_status").then(response => {
  954. this.sysFsSopWatchStatus = response.data;
  955. });
  956. listUser().then(res => {
  957. this.companyUserLists = res.rows;
  958. }
  959. );
  960. courseList().then(response => {
  961. this.courseList = response.list;
  962. });
  963. getMyQwCompanyList().then(response => {
  964. this.myQwCompanyList = response.data;
  965. if (this.myQwCompanyList != null) {
  966. this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
  967. this.refreshData(this.queryParams.corpId);
  968. this.getList();
  969. }
  970. });
  971. },
  972. watch: {
  973. userSelectList(newList) {
  974. this.form.qwUserIds = newList.map(item => item.id);
  975. }
  976. },
  977. methods: {
  978. voice(id) {
  979. this.voiceForm.queryParams.id = id;
  980. getSopVoiceList(this.voiceForm.queryParams).then(res => {
  981. this.voiceForm.list = res.rows;
  982. this.voiceForm.total = res.total;
  983. this.voiceForm.open = true;
  984. })
  985. },
  986. // 单元格点击事件
  987. handleCellClick(row, column, cell, event) {
  988. // 判断是否为规则编号列
  989. if (column.property === 'id') {
  990. this.handleRowClick(row); // 触发规则编号点击事件
  991. }
  992. },
  993. // handleUpdateTags(){
  994. //
  995. // },
  996. // handleUpdateQwUser(){
  997. //
  998. // },
  999. // handleUpdateSopTemp(){
  1000. //
  1001. // },
  1002. handleRowClick(row, column, event) {
  1003. // 判断状态是否符合条件
  1004. if (row.status == 2 || row.status == 0 || row.status == 3 || row.status == 4) {
  1005. this.handleUpdate(row, 2);
  1006. }
  1007. },
  1008. // 切换某一行的展开状态
  1009. toggleRow(row) {
  1010. this.$set(this.expandedRows, row.id, !this.expandedRows[row.id]);
  1011. },
  1012. getSwitchVal(status) {
  1013. return [2, 3, 4].includes(status) ? 2 : 0;
  1014. },
  1015. onSwitchChange(row, val) {
  1016. this.loading = true;
  1017. // ① 调用接口更新后端
  1018. updateSopStatus({id: row.id, status: val})
  1019. .then(() => {
  1020. row.status = val;
  1021. this.loading = false;
  1022. this.$message.success("切换成功!");
  1023. })
  1024. .catch(() => {
  1025. this.loading = false;
  1026. this.$message.error("操作失败,请重试");
  1027. });
  1028. },
  1029. switchSopStatusChange(row, checked) {
  1030. let loadingRock = this.$loading({
  1031. lock: true,
  1032. text: '暂停中-请勿刷新页面-重复点击',
  1033. spinner: 'el-icon-loading',
  1034. background: 'rgba(0, 0, 0, 0.7)'
  1035. });
  1036. updateSopStatus({id: row, status: checked}).then(response => {
  1037. this.$message.success("修改成功");
  1038. this.getList();
  1039. }).finally(res => {
  1040. loadingRock.close();
  1041. })
  1042. },
  1043. //新客户自动创建sop
  1044. switchAutoSopChange(row, checked) {
  1045. if (checked == 1) {
  1046. this.autoSopOpen.title = '请设置相应时间段'
  1047. this.autoSopOpen.open = true;
  1048. this.autoSopOpen.id = row;
  1049. this.autoSopOpen.isAutoSop = 1;
  1050. } else {
  1051. this.form.autoSopTime.createTime = this.formatDateTo24HourString(new Date());
  1052. updateAutoSopTime({
  1053. id: row,
  1054. isAutoSop: checked,
  1055. autoSopTime: JSON.stringify(this.form.autoSopTime)
  1056. }).then(response => {
  1057. this.getList();
  1058. })
  1059. }
  1060. },
  1061. updateCorpId() {
  1062. this.reset();
  1063. this.refreshData(this.queryParams.corpId);
  1064. this.queryParams.qwUserId = null;
  1065. this.getList();
  1066. },
  1067. //刷新部分数据
  1068. refreshData(row) {
  1069. getQwAllUserList(row).then(response => {
  1070. this.companyUserList = response.data;
  1071. });
  1072. listTag({corpId: row}).then(response => {
  1073. this.tagList = response.rows;
  1074. });
  1075. },
  1076. //查询模板
  1077. selectListSopTemp(type) {
  1078. this.tempListLoading = true; // 开始查询,显示加载提示
  1079. listSopTemp({sendType: type}).then(response => {
  1080. this.tempList = response.rows;
  1081. this.tempListLoading = false;
  1082. });
  1083. },
  1084. handlelistUser(type, sendType) {
  1085. setTimeout(() => {
  1086. this.$refs.QwUserList.getDetails(this.queryParams.corpId, type, sendType);
  1087. }, 1);
  1088. this.listUser.title = "选择企业成员"
  1089. this.listUser.open = true;
  1090. },
  1091. selectUserList(list) {
  1092. this.listUser.open = false;
  1093. list.forEach(obj => {
  1094. if (!this.userSelectList.some(item => item == obj.id)) {
  1095. this.userSelectList.push(obj.id);
  1096. }
  1097. });
  1098. },
  1099. //修改过期时间
  1100. handleUpdateOutTime(val) {
  1101. this.outTimeOpen.title = "修改过期时间/评级";
  1102. this.outTimeOpen.id = val.id;
  1103. this.outTimeOpen.tempId = val.tempId;
  1104. this.outTimeOpen.expiryTime = val.expiryTime;
  1105. this.outTimeOpen.isRating = val.isRating;
  1106. this.outTimeOpen.open = true;
  1107. },
  1108. handleUpdateExpiryTime() {
  1109. updateSop({
  1110. id: this.outTimeOpen.id,
  1111. tempId: this.outTimeOpen.tempId,
  1112. expiryTime: this.outTimeOpen.expiryTime,
  1113. isRating: this.outTimeOpen.isRating,
  1114. minConversionDay: this.outTimeOpen.minConversionDay,
  1115. maxConversionDay: this.outTimeOpen.maxConversionDay,
  1116. courseDay: this.outTimeOpen.courseDay
  1117. }).then(response => {
  1118. this.msgSuccess("修改成功");
  1119. this.resetUpdateExpiryTime()
  1120. this.getList();
  1121. });
  1122. },
  1123. resetUpdateExpiryTime() {
  1124. this.outTimeOpen = {
  1125. title: '',
  1126. open: false,
  1127. id: null,
  1128. expiryTime: null,
  1129. courseDay: null,
  1130. minConversionDay: null,
  1131. maxConversionDay: null,
  1132. isRating: null,
  1133. }
  1134. },
  1135. addContent(index) {
  1136. // this.setting[index].content.push({type:1})
  1137. if (this.form.sendType == 2) {
  1138. this.setting[index].content.push({type: 1});
  1139. } else {
  1140. if (this.setting[index].content.length < 9) {
  1141. this.setting[index].content.push({type: 1});
  1142. } else {
  1143. this.$message({
  1144. message: '最多只能添加 9 个内容',
  1145. type: 'warning'
  1146. });
  1147. }
  1148. }
  1149. },
  1150. //选择变动时的变动
  1151. handleSendTypeChange(val) {
  1152. this.tempList = [];
  1153. this.form.tempId = null;
  1154. if (val == 1) {
  1155. // 遍历 this.setting 数组并清空每个对象的 content 属性
  1156. this.setting.forEach(item => {
  1157. if (item.content.length > 9) {
  1158. item.content = item.content.slice(0, 9); // 保留前 9 个元素
  1159. }
  1160. });
  1161. }
  1162. },
  1163. delContent(index, contentIndex) {
  1164. this.setting[index].content.splice(contentIndex, 1)
  1165. },
  1166. //添加SOP规则类型
  1167. handleCommand(command) {
  1168. this.setting.push({
  1169. sopType: command,
  1170. ruleType: null,
  1171. name: null,
  1172. type: 1,
  1173. content: [],
  1174. isBindUrl: 1,
  1175. url: null,
  1176. day: "0",
  1177. hour: "0",
  1178. minute: "0",
  1179. time: ""
  1180. })
  1181. },
  1182. //添加课程SOP
  1183. handleCrouseCommand(command, val) {
  1184. console.log("command", command)
  1185. console.log("val", val)
  1186. },
  1187. delSetting(index) {
  1188. this.setting.splice(index, 1)
  1189. },
  1190. handleClosegroupUser(list) {
  1191. const index = this.userSelectList.findIndex(t => t === list);
  1192. if (index !== -1) {
  1193. this.userSelectList.splice(index, 1);
  1194. }
  1195. },
  1196. /** 查询企微sop列表 */
  1197. getList() {
  1198. this.loading = true;
  1199. listSop(this.queryParams).then(response => {
  1200. this.sopList = response.rows;
  1201. this.total = response.total;
  1202. this.loading = false;
  1203. listSopTemp().then(res => {
  1204. this.tempList = res.rows;
  1205. });
  1206. });
  1207. },
  1208. addSetList(){
  1209. const newSetting = {
  1210. contentType:'1',
  1211. value: '',
  1212. };
  1213. // 将新设置项添加到 content.setting 数组中
  1214. this.setting.push(newSetting);
  1215. },
  1216. handleContentTypeChange() {
  1217. //如果是链接的才上
  1218. if (this.msgForm.courseId != null ) {
  1219. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  1220. for (let i = 0; i < this.setting.length; i++) {
  1221. //响应式直接给链接的标题/封面上值
  1222. if (selectedCourse && this.setting[i].contentType == 3 && this.msgForm.courseId != null) {
  1223. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1224. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1225. }
  1226. }
  1227. }
  1228. if (this.msgForm.videoId != null ) {
  1229. // 查找选中的课节对应的 label
  1230. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  1231. for (let i = 0; i < this.setting.length; i++) {
  1232. //响应式直接给链接的描述上值
  1233. if (selectedVideo && this.setting[i].contentType == 3 && this.msgForm.videoId != null) {
  1234. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1235. }
  1236. }
  1237. }
  1238. },
  1239. videoIdChange() {
  1240. if (this.msgForm.videoId != null ) {
  1241. // 查找选中的课节对应的 label
  1242. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  1243. for (let i = 0; i < this.setting.length; i++) {
  1244. //响应式直接给链接的描述上值
  1245. if (selectedVideo && this.setting[i].contentType == 3 && this.msgForm.videoId != null) {
  1246. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1247. }
  1248. }
  1249. }
  1250. },
  1251. // 取消按钮
  1252. cancel() {
  1253. this.open = false;
  1254. this.reset();
  1255. },
  1256. // courseChange(){
  1257. // videoList(this.form.courseId).then(response => {
  1258. // this.videoList = response.list;
  1259. // });
  1260. // },
  1261. // 表单重置
  1262. reset() {
  1263. this.form = {
  1264. id: null,
  1265. name: null,
  1266. status: 1,
  1267. sendType: 2,
  1268. type: 2,
  1269. filterType: 2,
  1270. qwUserIds: null,
  1271. corpId: null,
  1272. setting: null,
  1273. createBy: null,
  1274. createTime: null,
  1275. isAutoSop: null,
  1276. autoSopTime: {autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2},
  1277. };
  1278. this.resetForm("form");
  1279. this.tags = null;
  1280. this.excludeTags = null;
  1281. },
  1282. /** 搜索按钮操作 */
  1283. handleQuery() {
  1284. this.queryParams.pageNum = 1;
  1285. this.getList();
  1286. },
  1287. /** 重置按钮操作 */
  1288. resetQuery() {
  1289. this.resetForm("queryForm");
  1290. this.queryParams.corpId = this.myQwCompanyList[0].dictValue;
  1291. this.refreshData(this.queryParams.corpId);
  1292. this.handleQuery();
  1293. },
  1294. // 多选框选中数据
  1295. handleSelectionChange(selection) {
  1296. this.ids = selection.map(item => item.id)
  1297. this.selectionMap = selection;
  1298. this.single = selection.length !== 1
  1299. this.multiple = !selection.length
  1300. },
  1301. /** 新增按钮操作 */
  1302. handleAdd() {
  1303. this.reset();
  1304. this.$router.push('/qw/sop/addSop/' + this.queryParams.corpId)
  1305. // this.open = true;
  1306. // this.setting=[]
  1307. // this.userSelectList=[]
  1308. // this.title = "添加企微sop";
  1309. },
  1310. /** 修改按钮操作 */
  1311. handleUpdate(row, type) {
  1312. this.$router.push('/qw/sop/updateSop/' + row.id + '/' + type)
  1313. },
  1314. /**
  1315. * 查看SOP任务内营期
  1316. */
  1317. selectSchedule(row) {
  1318. const query = {
  1319. id: row.id,
  1320. name: row.name,
  1321. tempId: row.tempId,
  1322. filterMode: row.filterMode
  1323. }
  1324. // 使用 params 传递参数
  1325. this.$router.push({
  1326. path: `/qw/sopUserLogs/sopUserLogsSchedule/${query.id}`,
  1327. query// 如果需要传递更多参数,可以使用 query
  1328. });
  1329. },
  1330. /**
  1331. * 查看营期内详情
  1332. */
  1333. handleScheduleDetail(row) {
  1334. this.sopLogsDialog.title = '规则执行详情';
  1335. this.sopLogsDialog.open = true;
  1336. this.sopLogsDialog.sopLogsForm = row;
  1337. },
  1338. handleAvatarSuccessFile(res, file, item) {
  1339. if (res.code === 200) {
  1340. // 使用 $set 确保响应式更新
  1341. this.$set(item, 'fileUrl', res.url);
  1342. } else {
  1343. this.msgError(res.msg);
  1344. }
  1345. },
  1346. beforeAvatarUploadFile(file){
  1347. const isLt1M = file.size / 1024 / 1024 < 10;
  1348. if (!isLt1M) {
  1349. this.$message.error('上传大小不能超过 10MB!');
  1350. }
  1351. return isLt1M;
  1352. },
  1353. //下载文件
  1354. downloadUrl(materialUrl) {
  1355. // 直接返回文件 URL
  1356. return materialUrl;
  1357. },
  1358. handleAvatarSuccessVideo(res, file, item) {
  1359. if(res.code==200){
  1360. // 使用 $set 确保响应式更新
  1361. this.$set(item, 'videoUrl', res.url);
  1362. }
  1363. else{
  1364. this.msgError(res.msg);
  1365. }
  1366. },
  1367. beforeAvatarUploadVideo(file){
  1368. const isLt30M = file.size / 1024 / 1024 < 10;
  1369. const isMP4 = file.type === 'video/mp4';
  1370. if (!isMP4) {
  1371. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  1372. return false;
  1373. }
  1374. if (!isLt30M) {
  1375. this.$message.error('上传大小不能超过 10MB!');
  1376. return false;
  1377. }
  1378. return true;
  1379. },
  1380. handleInputVideoText(value,content){
  1381. // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
  1382. const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
  1383. // 删除不符合条件的字符
  1384. const filteredValue = value.split('').filter(char => regex.test(char)).join('');
  1385. this.$set(content, 'value', filteredValue);
  1386. },
  1387. /**
  1388. * 查看模板
  1389. */
  1390. handleQueryDetails(row) {
  1391. this.$router.push(`/qw/sopTemp/updateSopTemp/${row.tempId}/3`)
  1392. },
  1393. /** 提交按钮 */
  1394. submitForm() {
  1395. this.$refs["form"].validate(valid => {
  1396. if (valid) {
  1397. if (this.userSelectList.length <= 0) {
  1398. return this.$message("请选择员工")
  1399. }
  1400. this.form.qwUserIds = this.userSelectList.join(",");
  1401. this.form.corpId = this.queryParams.corpId;
  1402. if (this.tags != null && this.tags.length > 0) {
  1403. this.form.tags = (this.tags).toString()
  1404. } else {
  1405. return this.$message.error("选择的标签不能为空!!请选择筛选的标签")
  1406. }
  1407. if (this.excludeTags != null) {
  1408. this.form.excludeTags = (this.excludeTags).toString()
  1409. }
  1410. this.form.setting = JSON.stringify(this.setting)
  1411. if (this.form.id != null) {
  1412. updateSop(this.form).then(response => {
  1413. this.msgSuccess("修改成功");
  1414. this.open = false;
  1415. this.getList();
  1416. });
  1417. } else {
  1418. addSop(this.form).then(response => {
  1419. this.msgSuccess("新增成功");
  1420. this.open = false;
  1421. this.getList();
  1422. });
  1423. }
  1424. }
  1425. });
  1426. },
  1427. submitAutoSopTimeFrom() {
  1428. this.$refs["autoSopTimeFrom"].validate(valid => {
  1429. if (valid) {
  1430. this.autoSopOpen.open = false
  1431. this.form.autoSopTime.createTime = this.formatDateTo24HourString(new Date());
  1432. updateAutoSopTime({
  1433. id: this.autoSopOpen.id,
  1434. isAutoSop: this.autoSopOpen.isAutoSop,
  1435. autoSopTime: JSON.stringify(this.form.autoSopTime)
  1436. }).then(response => {
  1437. this.msgSuccess("修改成功");
  1438. });
  1439. }
  1440. this.getList();
  1441. this.reset();
  1442. });
  1443. },
  1444. formatDateTo24HourString(date) {
  1445. let year = date.getFullYear();
  1446. let month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份需要加 1 并补零
  1447. let day = ('0' + date.getDate()).slice(-2); // 日需要补零
  1448. let hours = ('0' + date.getHours()).slice(-2); // 小时需要补零
  1449. let minutes = ('0' + date.getMinutes()).slice(-2); // 分钟需要补零
  1450. let seconds = ('0' + date.getSeconds()).slice(-2); // 秒需要补零
  1451. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  1452. },
  1453. cancelAutoSopTime() {
  1454. this.autoSopOpen.open = false
  1455. this.getList();
  1456. },
  1457. /** 删除按钮操作 */
  1458. handleDelete(row) {
  1459. const ids = row.id || this.ids;
  1460. this.$confirm('是否确认删除企微sop编号为"' + ids + '"的数据项?', "警告", {
  1461. confirmButtonText: "确定",
  1462. cancelButtonText: "取消",
  1463. type: "warning"
  1464. }).then(function () {
  1465. return delSop(ids);
  1466. }).then(() => {
  1467. this.getList();
  1468. this.msgSuccess("删除成功");
  1469. }).catch(() => {
  1470. });
  1471. },
  1472. /**
  1473. * 批量执行SOP任务
  1474. */
  1475. handleExecute() {
  1476. const ids = this.selectionMap
  1477. .filter(item => item.status === 1)
  1478. .map(item => item.id);
  1479. if (ids.length === 0) {
  1480. this.msgError("选择的任务已经执行或正在执行,请选择待执行的任务");
  1481. return;
  1482. }
  1483. this.$confirm('是否确认立即执行sop编号为"' + ids + '"的数据项?', "警告【只能立即执行(待执行的)】", {
  1484. confirmButtonText: "确定",
  1485. cancelButtonText: "取消",
  1486. type: "warning"
  1487. }).then(() => {
  1488. this.loading = true;
  1489. // 执行更新操作
  1490. return updateStatus(ids); // 返回一个Promise,直接在此链式调用
  1491. }).then(res => {
  1492. let msg = "";
  1493. // 判断成功和失败的任务,并显示消息
  1494. if (res.suc.length > 0) {
  1495. msg += "执行成功的SOP任务【" + res.suc.join(", ") + "】。<br>"; // 优化:将数组转换为字符串
  1496. }
  1497. if (res.err.length > 0) {
  1498. msg += "失败的SOP任务【" + res.err.join(", ") + "】,原因是已经执行或正在执行。<br>";
  1499. }
  1500. // 显示确认框,显示成功与失败信息
  1501. return this.$confirm(msg, "提示", {
  1502. confirmButtonText: "确定",
  1503. cancelButtonText: "取消",
  1504. type: "warning",
  1505. dangerouslyUseHTMLString: true // 允许HTML标签
  1506. });
  1507. }).then(() => {
  1508. // 操作完成后刷新列表,并显示成功信息
  1509. this.getList();
  1510. this.msgSuccess("执行完成");
  1511. }).catch(() => {
  1512. // 处理任何异常,操作取消或者失败时显示提示信息
  1513. this.msgError("操作失败,请重试");
  1514. }).finally(() => {
  1515. this.loading = false; // 操作完成后关闭加载状态
  1516. });
  1517. },
  1518. /** 导出按钮操作 */
  1519. handleExport() {
  1520. const queryParams = this.queryParams;
  1521. this.$confirm('是否确认导出所有企微sop数据项?', "警告", {
  1522. confirmButtonText: "确定",
  1523. cancelButtonText: "取消",
  1524. type: "warning"
  1525. }).then(() => {
  1526. this.exportLoading = true;
  1527. return exportSop(queryParams);
  1528. }).then(response => {
  1529. this.download(response.msg);
  1530. this.exportLoading = false;
  1531. }).catch(() => {
  1532. });
  1533. },
  1534. /**
  1535. * 一键群发
  1536. */
  1537. handleSendMsg(row){
  1538. this.sendMsgOpen.open = true;
  1539. this.sendMsgOpen.id = row.id;
  1540. this.sendMsgOpen.row = row;
  1541. },
  1542. submitMsgForm(){
  1543. this.$refs["msgForm"].validate(valid => {
  1544. if (valid) {
  1545. this.msgForm.setting=JSON.stringify(this.setting)
  1546. this.msgForm.sopId=this.sendMsgOpen.row.id;
  1547. this.msgForm.filterMode=this.sendMsgOpen.row.filterMode;
  1548. if (this.setting.length <= 0) {
  1549. return this.$message.error("请添加规则")
  1550. }
  1551. if (this.msgForm.courseId===null || this.msgForm.courseId===''){
  1552. return this.$message.error("课程不能为空")
  1553. }
  1554. if (this.msgForm.videoId===null || this.msgForm.videoId===''){
  1555. return this.$message.error("课节不能为空")
  1556. }
  1557. if (this.msgForm.courseType===null || this.msgForm.courseType===''){
  1558. return this.$message.error("消息类型不能为空")
  1559. }
  1560. for (let i = 0; i < this.setting.length; i++) {
  1561. if (this.setting[i].contentType == 1 && (this.setting[i].value == null || this.setting[i].value == "")) {
  1562. return this.$message.error("内容不能为空")
  1563. }
  1564. if (this.setting[i].contentType == 2 && (this.setting[i].imgUrl == null || this.setting[i].imgUrl == "")) {
  1565. return this.$message.error("图片不能为空")
  1566. }
  1567. if (this.setting[i].contentType == 3 && (this.setting[i].linkTitle == null || this.setting[i].linkTitle == "")) {
  1568. return this.$message.error("链接标题不能为空")
  1569. }
  1570. if (this.setting[i].contentType == 3 && (this.setting[i].linkDescribe == null || this.setting[i].linkDescribe == "")) {
  1571. return this.$message.error("链接描述不能为空")
  1572. }
  1573. if (this.setting[i].contentType == 3 && (this.setting[i].linkImageUrl == null || this.setting[i].linkImageUrl == "")) {
  1574. return this.$message.error("链接图片不能为空")
  1575. }
  1576. if (this.setting[i].contentType == 3 && this.setting[i].type == 1 && (this.setting[i].linkUrl == null || this.setting[i].linkUrl == "")) {
  1577. return this.$message.error("链接地址不能为空")
  1578. }
  1579. if (this.setting[i].contentType == 5 && (this.setting[i].fileUrl == null || this.setting[i].fileUrl == "")) {
  1580. return this.$message.error("文件不能为空")
  1581. }
  1582. if (this.setting[i].contentType == 6 && (this.setting[i].videoUrl == null || this.setting[i].videoUrl == "")) {
  1583. return this.$message.error("视频不能为空")
  1584. }
  1585. if (this.setting[i].contentType == 7 && (this.setting[i].value == null || this.setting[i].value == "")) {
  1586. return this.$message.error("语音不能为空")
  1587. }
  1588. }
  1589. this.sendMsgOpen.open = false;
  1590. const loading = this.$loading({
  1591. lock: true,
  1592. text: '正在执行中请稍后~~请不要刷新页面!!',
  1593. spinner: 'el-icon-loading',
  1594. background: 'rgba(0, 0, 0, 0.7)'
  1595. });
  1596. sendMsgSop(this.msgForm).then(response => {
  1597. this.msgSuccess("一键群发成功");
  1598. loading.close();
  1599. this.setting=[];
  1600. this.msgForm = {
  1601. videoId:null,
  1602. courseId:null,
  1603. courseType:null,
  1604. setting:null,
  1605. isRegister:2,
  1606. }
  1607. this.getList();
  1608. }).finally(()=>{
  1609. loading.close();
  1610. });
  1611. }
  1612. });
  1613. },
  1614. courseChange() {
  1615. if (this.msgForm.courseId != null ) {
  1616. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  1617. for (let i = 0; i < this.setting.length; i++) {
  1618. //响应式直接给链接的标题/封面上值
  1619. if (selectedCourse && this.setting[i].contentType == 3 && this.msgForm.courseId != null) {
  1620. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1621. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1622. }
  1623. }
  1624. }
  1625. videoList(this.msgForm.courseId).then(response => {
  1626. this.videoList=response.list;
  1627. });
  1628. },
  1629. cancelMsgForm(){
  1630. this.sendMsgOpen.open = false;
  1631. this.resetSendMsgSop();
  1632. },
  1633. }
  1634. };
  1635. </script>
  1636. <style scoped>
  1637. .custom-input /deep/ .el-input__inner {
  1638. height: 20px;
  1639. padding: 0 4px;
  1640. text-align: center;
  1641. display: block;
  1642. }
  1643. .custom-input /deep/ .el-input__icon {
  1644. line-height: 20px;
  1645. }
  1646. .el-button--text {
  1647. cursor: pointer;
  1648. }
  1649. </style>