updateSop.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. <template>
  2. <div class="app-container">
  3. <div style="margin: 30px;" v-if="handleType==1"> 修改sop任务</div>
  4. <div style="margin: 30px;" v-if="handleType==2"> 查看sop任务
  5. <div style="float: right">
  6. <!-- <el-button-->
  7. <!-- type="primary"-->
  8. <!-- @click="handleUpdateTags()"-->
  9. <!-- v-hasPermi="['qw:sop:remove']"-->
  10. <!-- >修改标签</el-button>-->
  11. <el-button
  12. type="primary"
  13. @click="handleUpdateQwUser()"
  14. v-hasPermi="['qw:sop:updateSopQwUser']"
  15. >修改员工</el-button>
  16. <el-button
  17. type="primary"
  18. @click="handleUpdateSopTemp()"
  19. v-hasPermi="['qw:sop:updateSopTemp']"
  20. >修改模板</el-button>
  21. </div>
  22. <el-divider></el-divider>
  23. <el-alert
  24. title="注意事项"
  25. type="warning"
  26. description="【持续生成记录中的状态】 的SOP任务仅能查看,不能修改(ps:可以在外面修改【过期时间】和【新客户自动创建sop】)"
  27. :closable="false"
  28. show-icon>
  29. </el-alert>
  30. </div>
  31. <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 60px;">
  32. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  33. <el-form-item label="规则名称" prop="name">
  34. <el-input v-model="form.name" placeholder="请输入规则名称" />
  35. </el-form-item>
  36. <el-form-item label="状态" prop="status">
  37. <dict-tag :options="statusOptions" :value="form.status"></dict-tag>
  38. </el-form-item>
  39. <!-- <el-form-item label="状态">-->
  40. <!-- <el-radio-group v-model="form.status">-->
  41. <!-- <el-radio-->
  42. <!-- v-for="dict in statusOptions"-->
  43. <!-- :label="dict.dictValue"-->
  44. <!-- >{{dict.dictLabel}}</el-radio>-->
  45. <!-- </el-radio-group>-->
  46. <!-- </el-form-item>-->
  47. <el-form-item label="类别" prop="type">
  48. <el-radio-group v-model="form.type">
  49. <el-radio
  50. :label="1"
  51. >个微</el-radio>
  52. <el-radio
  53. :label="2"
  54. >企微</el-radio>
  55. </el-radio-group>
  56. <Tip title="针对于企业微信平台" />
  57. </el-form-item>
  58. <el-form-item label="小转天数" prop="minConversionDay">
  59. <el-input class="el-input" v-model="form.minConversionDay" placeholder="请输入" style="width: 300px">
  60. <template slot="append">天</template>
  61. </el-input>
  62. <Tip title="第一次提醒销售,去联系客户,在【催课看板】处显示,哪些需要联系的客户" />
  63. </el-form-item>
  64. <el-form-item label="大转天数" prop="maxConversionDay">
  65. <el-input class="el-input" v-model="form.maxConversionDay" placeholder="请输入" style="width: 300px">
  66. <template slot="append">天</template>
  67. </el-input>
  68. <Tip title="第二次提醒销售,去联系客户,在【催课看板】处显示,哪些需要联系的客户" />
  69. </el-form-item>
  70. <div v-if="form.type==2">
  71. <el-form-item label="推送方式 ">
  72. <el-radio-group v-model="form.sendType" @input="handleSendTypeChange">
  73. <el-radio
  74. v-for="dict in sysQwSopType"
  75. :key="dict.dictValue"
  76. :label="parseInt(dict.dictValue)"
  77. >{{dict.dictLabel}}</el-radio>
  78. </el-radio-group>
  79. <Tip title="选择模板类型" />
  80. </el-form-item>
  81. <el-form-item label="选择员工" prop="qwUserIds" style="margin-top: 2%">
  82. <div>
  83. <el-button
  84. size="medium"
  85. icon="el-icon-circle-plus-outline"
  86. plain
  87. @click="handlelistUser(form.type,form.sendType)">请选择使用员工</el-button>
  88. </div>
  89. <div>
  90. <el-tag
  91. style="margin-left: 5px"
  92. size="medium"
  93. :key="id"
  94. v-for="id in userSelectList"
  95. :disable-transitions="false"
  96. @close="handleClosegroupUser(id)">
  97. <span v-for="list in companyUserList" :key="list.qwUserId" v-if="list.id==id">{{list.qwUserName}}</span>
  98. </el-tag>
  99. </div>
  100. </el-form-item>
  101. <el-form-item label="是否自动创建群" prop="autoGroup" v-if="form.filterMode == 2">
  102. <el-radio-group v-model="form.autoGroup">
  103. <el-radio
  104. :label="0"
  105. >否
  106. </el-radio>
  107. <el-radio
  108. :label="1"
  109. >是
  110. </el-radio>
  111. </el-radio-group>
  112. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  113. <i class="el-icon-info"></i>
  114. 选择的企业微信员工下面的群聊
  115. </div>
  116. </el-form-item>
  117. <el-form-item label="是否注册用户" prop="autoGroup" v-if="form.filterMode == 2 && form.autoGroup == 1">
  118. <el-radio-group v-model="form.autoUserReg">
  119. <el-radio
  120. :label="0"
  121. >否
  122. </el-radio>
  123. <el-radio
  124. :label="1"
  125. >是
  126. </el-radio>
  127. </el-radio-group>
  128. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  129. <i class="el-icon-info"></i>
  130. 筛选是否注册的用户
  131. </div>
  132. </el-form-item>
  133. <el-form-item label="创建群聊评级" prop="chatIds" v-if="form.filterMode == 2 && form.autoGroup == 1">
  134. <el-select multiple filterable clearable v-model="form.autoGroupLevelArray">
  135. <el-option v-for="item in levelList" :key="item.value" :label="item.label" :value="item.value"/>
  136. </el-select>
  137. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  138. <i class="el-icon-info"></i>
  139. 选择需要拉取的客户评级
  140. </div>
  141. </el-form-item>
  142. <el-form-item label="群聊名称" prop="chatIds" v-if="form.filterMode == 2 && form.autoGroup == 1">
  143. <el-input v-model="form.groupName" maxlength="10" placeholder="请输入群聊名称" />
  144. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  145. <i class="el-icon-info"></i>
  146. 创建群聊的名称(如有重复自动加数字区分)
  147. </div>
  148. </el-form-item>
  149. <el-form-item label="标签规则" prop="filterType">
  150. <el-radio-group v-model="form.filterType">
  151. <el-radio
  152. :label="1"
  153. >含全部标签</el-radio>
  154. <el-radio
  155. :label="2"
  156. >含任意标签</el-radio>
  157. </el-radio-group>
  158. </el-form-item>
  159. <el-form-item label="选择的标签" prop="tags">
  160. <el-select v-model="tags" remote multiple placeholder="请选择" filterable style="width: 100%;">
  161. <el-option
  162. v-for="dict in tagList"
  163. :label="dict.name"
  164. :value="dict.tagId">
  165. </el-option>
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="排除的标签" prop="excludeTags">
  169. <el-select v-model="excludeTags" remote multiple placeholder="请选择" filterable style="width: 100%;">
  170. <el-option
  171. v-for="dict in tagList"
  172. :label="dict.name"
  173. :value="dict.tagId">
  174. </el-option>
  175. </el-select>
  176. </el-form-item>
  177. </div>
  178. <div v-if="form.type==1">
  179. <el-form-item label="推送方式 ">
  180. <el-tag type="success" v-model="form.sendType=2">AI插件</el-tag>
  181. </el-form-item>
  182. <el-form-item label="标签规则" prop="filterType">
  183. <el-radio-group v-model="form.filterType">
  184. <el-radio
  185. :label="1"
  186. >含全部分组</el-radio>
  187. <el-radio
  188. :label="2"
  189. >含任意分组</el-radio>
  190. </el-radio-group>
  191. </el-form-item>
  192. <el-form-item label="选择的分组" prop="tags">
  193. <el-select v-model="tags" remote multiple placeholder="请选择" filterable style="width: 100%;">
  194. <el-option
  195. v-for="dict in wxUserGroupList"
  196. :label="dict.groupName"
  197. :value="dict.groupId.toString()">
  198. </el-option>
  199. </el-select>
  200. </el-form-item>
  201. </div>
  202. <el-form-item label="是否固定营期" prop="isFixed" v-if="form.type != 3">
  203. <el-radio-group v-model="form.isFixed">
  204. <el-radio
  205. :label="1"
  206. >是
  207. </el-radio>
  208. <el-radio
  209. :label="0"
  210. >否
  211. </el-radio>
  212. </el-radio-group>
  213. <Tip title="如果为固定营期,不管什么时候进入SOP的客户,营期时间都为SOP任务开始时间" />
  214. </el-form-item>
  215. <el-form-item label="开始时间" prop="startTime">
  216. <el-date-picker clearable size="small"
  217. v-model="form.startTime"
  218. type="date"
  219. value-format="yyyy-MM-dd"
  220. placeholder="选择开始时间">
  221. </el-date-picker>
  222. </el-form-item>
  223. <el-form-item label="是否只发送注册用户" prop="isRegister" v-if="form.type != 3">
  224. <el-radio-group v-model="form.isRegister">
  225. <el-radio
  226. :label="1"
  227. >是
  228. </el-radio>
  229. <el-radio
  230. :label="0"
  231. >否
  232. </el-radio>
  233. </el-radio-group>
  234. <Tip title="是否只发送在平台注册了会员的客户" />
  235. </el-form-item>
  236. <el-form-item v-if="form.sendType==2 || form.sendType==4" label="自动添加SOP" prop="autoSopTime" >
  237. <el-radio-group v-model="form.autoSopTime.autoSopType">
  238. <el-radio
  239. :label="1"
  240. >当天开始</el-radio>
  241. <el-radio
  242. :label="2"
  243. >次日开始</el-radio>
  244. </el-radio-group>
  245. <Tip :title="'这个选项仅作用于【新客户】进线时或【给客户打标签时】,是进入当日的营期 还是 次日的营期'" />
  246. </el-form-item>
  247. <div style="display: flex; align-items: center; flex-wrap: nowrap;">
  248. <div v-if="form.autoSopTime.autoSopType==1" style="display: flex; align-items: center">
  249. <el-form-item
  250. label="起始时间"
  251. prop="autoStartTime"
  252. label-width="100px"
  253. style="margin: 2% 0;align-items: center;">
  254. <el-time-select
  255. style="width: 120px;"
  256. placeholder="起始时间"
  257. v-model="form.autoSopTime.autoStartTime"
  258. :picker-options="{
  259. start: '00:00',
  260. step: '00:15',
  261. end: '24:00'
  262. }">
  263. </el-time-select>
  264. </el-form-item>
  265. <el-form-item
  266. label="结束时间"
  267. prop="autoEndTime"
  268. label-width="100px"
  269. style="margin: 2% 0; align-items: center; ">
  270. <el-time-select
  271. style="width: 120px;"
  272. placeholder="结束时间"
  273. v-model="form.autoSopTime.autoEndTime"
  274. :picker-options="{
  275. start: '00:00',
  276. step: '00:15',
  277. end: '24:00',
  278. minTime: form.autoSopTime.autoEndTime
  279. }">
  280. </el-time-select>
  281. </el-form-item>
  282. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  283. <i class="el-icon-info"></i>
  284. 起始时间-结束时间之内的进线客户,进入【当日营期】,时间之外的,进入【次日营期】
  285. </div>
  286. </div>
  287. </div>
  288. <el-form-item label="任务过期时间" prop="expiryTime">
  289. <el-row>
  290. <el-input-number v-model="form.expiryTime" :min="1" :max="100" ></el-input-number>
  291. (小时)
  292. </el-row>
  293. <Tip title="发送sop任务消息的过期时间,超过这个时间,消息将不再发送(作废),比如:9点的消息,设置3个小时过期,12点之后还未发送 则这条消息将过期且不再发送" />
  294. </el-form-item>
  295. <el-form-item label="模板" prop="tempId">
  296. <div @click="selectListSopTemp(form.sendType,0)" style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;">
  297. <el-tag type="success" style="margin: 3px;"
  298. :disable-transitions="false"
  299. v-for="list in tempList"
  300. :key="list.id"
  301. v-if="list.id === form.tempId">
  302. {{ form.tempName || list.name }}
  303. </el-tag>
  304. <!-- 如果 form.tempId 没有值,显示 '请选择模板' -->
  305. <span v-if="!form.tempId" style="margin: 3px; color: #999;">请选择模板</span>
  306. </div>
  307. <!-- <el-select v-model="form.tempId" @focus="selectListSopTemp(form.sendType)" placeholder="请选择模板" v-loading="tempListLoading" >-->
  308. <!-- <el-option-->
  309. <!-- v-for="dict in tempList"-->
  310. <!-- :label="dict.name"-->
  311. <!-- :value="dict.id">-->
  312. <!-- </el-option>-->
  313. <!-- <div v-if="tempListLoading" slot="prefix" class="select-prefix">正在查询相应模板...</div>-->
  314. <!-- </el-select>-->
  315. </el-form-item>
  316. <el-form-item label="开启评论/弹幕" prop="openCommentStatus">
  317. <el-radio-group v-model="form.openCommentStatus">
  318. <el-radio :label="1" >开启评论</el-radio>
  319. <el-radio :label="2" >开启弹幕</el-radio>
  320. <el-radio :label="3" >关闭</el-radio>
  321. </el-radio-group>
  322. </el-form-item>
  323. </el-form>
  324. <div slot="footer" class="dialog-footer" style="float: right;" >
  325. <el-button v-if="handleType==1" type="primary" @click="submitForm">确 定</el-button>
  326. <el-button v-if="handleType==1" @click="cancel">取 消</el-button>
  327. </div>
  328. <el-dialog :custom-class="'fixed-dialog'" :title="listUser.title" :visible.sync="listUser.open" width="700px" append-to-body>
  329. <qwUserList ref="QwUserList" @selectUserList="selectUserList"></qwUserList>
  330. </el-dialog>
  331. <el-dialog title="选择模板" :visible.sync="tempOpen" append-to-body >
  332. <sop-temp ref="SopTempComments" @sopTemp="sopTemp" @submitUpdateTemp="submitUpdateTemp"></sop-temp>
  333. </el-dialog>
  334. <!-- 修改模板 -->
  335. <el-dialog :title="updateQwUserDialog.title" :visible.sync="updateQwUserDialog.open" width="500px" append-to-body>
  336. <el-form ref="form" :model="form" label-width="100px">
  337. <el-form-item label="选择员工" prop="qwUserIds" style="margin-top: 2%">
  338. <div>
  339. <el-button
  340. size="medium"
  341. icon="el-icon-circle-plus-outline"
  342. plain
  343. @click="handlelistUser(form.type,form.sendType)">请选择使用员工</el-button>
  344. </div>
  345. <div>
  346. <el-tag
  347. style="margin-left: 5px"
  348. size="medium"
  349. :key="id"
  350. v-for="id in userSelectList"
  351. closable
  352. :disable-transitions="false"
  353. @close="handleClosegroupUser(id)">
  354. <span v-for="list in companyUserList" :key="list.qwUserId" v-if="list.id==id">{{list.qwUserName}}</span>
  355. </el-tag>
  356. </div>
  357. </el-form-item>
  358. </el-form>
  359. <div slot="footer" class="dialog-footer" >
  360. <el-button type="primary" @click="submitUpdateQwUser">确 定</el-button>
  361. <el-button @click="cancel">取 消</el-button>
  362. </div>
  363. </el-dialog>
  364. </div>
  365. </div>
  366. </template>
  367. <script>
  368. import { listSop, getSop, delSop, addSop, updateSop, exportSop,courseList,videoList,updateSopQwUser } from "@/api/qw/sop";
  369. import { listSopTemp, getSopTemp, delSopTemp, addSopTemp, updateSopTemp, exportSopTemp } from "@/api/qw/sopTemp";
  370. import { getQwAllUserList } from '@/api/company/companyUser'
  371. import qwUserList from '@/views/qw/user/qwUserList.vue'
  372. import ImageUpload from "@/views/qw/sop/ImageUpload";
  373. import CustomerGroupDetails from '@/views/qw/groupMsg/customerGroupDetails.vue'
  374. import sopLogsDetails from '@/views/qw/sopLogs/sopLogsList.vue'
  375. import { listTag, getTag, } from "@/api/qw/tag";
  376. import {getMyQwUserList, getMyQwCompanyList, getQwUserByIds} from "@/api/qw/user";
  377. import {sopListWxUserGroup} from "@/api/wxUser/wxUserGroup";
  378. import source from "echarts/src/data/Source";
  379. import SopTemp from "@/views/qw/sopTemp/sopTemp.vue";
  380. import Tip from "../../../components/Tip/index.vue";
  381. // import { ElMessageBox } from 'element-plus';
  382. export default {
  383. name: "updateSop",
  384. components: {Tip, SopTemp, CustomerGroupDetails, qwUserList,ImageUpload,sopLogsDetails},
  385. data() {
  386. return {
  387. levelList: [
  388. {value: 1, label: "A"},
  389. {value: 2, label: "B"},
  390. {value: 3, label: "C"},
  391. {value: 4, label: "D"},
  392. {value: 5, label: "E"},
  393. {value: -1, label: "未评级"},
  394. ],
  395. updateQwUserDialog:{
  396. title:"修改成员",
  397. open:false
  398. },
  399. updateQwUserForm:{},
  400. handleType:null,
  401. //模板查询
  402. tempListLoading:false,
  403. // 遮罩层
  404. loading: true,
  405. // 导出遮罩层
  406. exportLoading: false,
  407. //模板遮罩
  408. tempOpen:false,
  409. // 选中数组
  410. ids: [],
  411. courseList:[],
  412. // videoList:[],
  413. tags:[],
  414. excludeTags:null,
  415. // 非单个禁用
  416. single: true,
  417. setting:[],
  418. tagList:[],
  419. tempList:[],
  420. // 非多个禁用
  421. multiple: true,
  422. // 显示搜索条件
  423. showSearch: true,
  424. // 总条数
  425. total: 0,
  426. // 企微sop表格数据
  427. sopList: [],
  428. // 弹出层标题
  429. title: "",
  430. // 是否显示弹出层
  431. open: false,
  432. companyUserList:[],
  433. // 状态字典
  434. statusOptions: [],
  435. //企微SOP发送类型
  436. sysQwSopType: [],
  437. //个微客户的分组
  438. wxUserGroupList:[],
  439. sopLogsDialog:{
  440. title:'',
  441. open:false,
  442. sopLogsForm:[],
  443. },
  444. // 表单参数
  445. form: {
  446. status: 1,
  447. sendType:2,
  448. type: 2,
  449. autoGroupLevelArray:[],
  450. filterType:2,
  451. autoSopTime:{},
  452. },
  453. userSelectList:[],
  454. listUser:{
  455. title:"",
  456. open:false
  457. },
  458. // 表单校验
  459. rules: {
  460. name:[ { required: true, message: "名称不能为空", trigger: "submit" }],
  461. type:[ { required: true, message: "不能为空", trigger: "submit" }],
  462. sendType:[ { required: true, message: "不能为空", trigger: "submit" }],
  463. startTime:[ { required: true, message: "开始时间不能为空", trigger: "submit" }],
  464. tempId:[ { required: true, message: "模板不能为空", trigger: "submit" }],
  465. }
  466. };
  467. },
  468. created() {
  469. this.getDicts("sys_sop_status").then(response => {
  470. this.statusOptions = response.data;
  471. console.log(" this.statusOptions:"+ this.statusOptions)
  472. });
  473. this.getDicts("sys_qw_sop_type").then(response => {
  474. this.sysQwSopType = response.data;
  475. });
  476. const id = this.$route.params && this.$route.params.id;
  477. this.handleType = this.$route.params && this.$route.params.type;
  478. this.handleUpdate(id);
  479. //个微客户的分组
  480. sopListWxUserGroup().then(response => {
  481. this.wxUserGroupList = response.rows;
  482. });
  483. courseList().then(response => {
  484. this.courseList = response.list;
  485. });
  486. },
  487. watch:{
  488. userSelectList(newList) {
  489. this.form.qwUserIds = newList.map(item => item.id);
  490. }
  491. },
  492. methods: {
  493. submitUpdateQwUser(){
  494. this.form.qwUserIds = this.userSelectList.join(",");
  495. const data ={
  496. id:this.form.id,
  497. qwUserIds: this.form.qwUserIds
  498. }
  499. this.$confirm(
  500. '<span style="color: red; margin-bottom: 10px">是否确认修改当前任务员工?</span>' +
  501. '<span style="color: red;">(如有删除员工,对应的【营期也会删除】且【不可恢复】,请谨慎操作)</span>',
  502. "警告",
  503. {
  504. confirmButtonText: "确定",
  505. cancelButtonText: "取消",
  506. type: "warning",
  507. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  508. }).then(() => {
  509. this.updateQwUserDialog.open=false;
  510. return updateSopQwUser(data);
  511. }).then(response => {
  512. this.handleUpdate(data.id);
  513. this.msgSuccess("修改员工成功");
  514. this.updateQwUserDialog.open=false;
  515. }).catch(() => {
  516. });
  517. },
  518. handleUpdateTags(){
  519. },
  520. handleUpdateQwUser(){
  521. this.updateQwUserDialog.open = true
  522. },
  523. handleUpdateSopTemp(){
  524. this.selectListSopTemp(this.form.sendType,1)
  525. },
  526. //刷新部分数据
  527. refreshData(row){
  528. getQwAllUserList(row).then(response => {
  529. this.companyUserList = response.data;
  530. });
  531. listTag({corpId:row}).then(response => {
  532. this.tagList = response.rows;
  533. });
  534. },
  535. //查询模板
  536. selectListSopTemp(type,isUpdate){
  537. this.tempListLoading = true; // 开始查询,显示加载提示
  538. listSopTemp({sendType:type}).then(response => {
  539. this.tempList = response.rows;
  540. this.tempListLoading = false;
  541. });
  542. this.tempOpen = true;
  543. setTimeout(() => {
  544. this.$refs.SopTempComments.getList(type,isUpdate);
  545. }, 200);
  546. },
  547. //确认修改模板
  548. submitUpdateTemp(val){
  549. console.log(val)
  550. const data = {
  551. tempId : val.id,
  552. tempName : val.name,
  553. id : this.form.id
  554. }
  555. this.$confirm('是否确认修改当前任务的模板为"' + data.tempName + '"?', "警告", {
  556. confirmButtonText: "确定",
  557. cancelButtonText: "取消",
  558. type: "warning"
  559. }).then(() => {
  560. this.tempOpen=false;
  561. return updateSop(data);
  562. }).then(response => {
  563. this.handleUpdate(data.id);
  564. this.msgSuccess("修改模板成功");
  565. this.tempOpen=false;
  566. }).catch(() => {
  567. });
  568. },
  569. sopTemp(val){
  570. this.form.tempId=val.id
  571. this.form.tempName=val.name
  572. this.tempOpen=false;
  573. },
  574. handlelistUser(type,sendType){
  575. setTimeout(() => {
  576. this.$refs.QwUserList.getDetails(this.form.corpId,type,sendType);
  577. }, 1);
  578. this.listUser.title="选择企业成员"
  579. this.listUser.open=true;
  580. },
  581. selectUserList(list){
  582. this.listUser.open=false;
  583. list.forEach(obj => {
  584. if (!this.userSelectList.some(item => item == obj.id)) {
  585. this.userSelectList.push(obj.id);
  586. }
  587. });
  588. },
  589. //选择变动时的变动
  590. handleSendTypeChange(val){
  591. this.tempList=[];
  592. this.userSelectList=[];
  593. this.form.tempId=null;
  594. if (val==1) {
  595. // 遍历 this.setting 数组并清空每个对象的 content 属性
  596. this.setting.forEach(item => {
  597. if (item.content.length > 9) {
  598. item.content = item.content.slice(0, 9); // 保留前 9 个元素
  599. }
  600. });
  601. }
  602. },
  603. //删除员工
  604. handleClosegroupUser(id){
  605. // const index = this.userSelectList.findIndex(t => t === list);
  606. console.log(id)
  607. // if (index !== -1) {
  608. // this.userSelectList.splice(index, 1);
  609. // }
  610. // 找到对应的员工信息
  611. const user = this.companyUserList.find((list) => list.id == id);
  612. console.log(user)
  613. if (!user) return;
  614. // 确认删除提醒
  615. this.$confirm('确定要删除员工"'+user.qwUserName+'"吗?', '提示', {
  616. confirmButtonText: '确定',
  617. cancelButtonText: '取消',
  618. type: 'warning',
  619. })
  620. .then(() => {
  621. // 用户点击确定
  622. const index = this.userSelectList.findIndex((t) => t === id);
  623. if (index !== -1) {
  624. this.userSelectList.splice(index, 1);
  625. }
  626. this.$message({
  627. type: 'success',
  628. message: '删除成功',
  629. });
  630. })
  631. .catch(() => {
  632. // 用户点击取消
  633. this.$message({
  634. type: 'info',
  635. message: '已取消删除',
  636. });
  637. });
  638. },
  639. // 取消按钮
  640. cancel() {
  641. this.$store.dispatch("tagsView/delView", this.$route);
  642. this.$router.replace('/qw/conversion/sop')
  643. this.reset();
  644. },
  645. /** 修改按钮操作 */
  646. handleUpdate(row) {
  647. this.reset();
  648. getSop(row).then(response => {
  649. this.form = response.data;
  650. this.form.autoSopTime=JSON.parse(response.data.autoSopTime)
  651. this.open = true;
  652. this.userSelectList = this.form.qwUserIds.split(",");
  653. if (this.form.tags!==''&&this.form.tags!=null){
  654. this.tags = this.form.tags.split(",");
  655. }
  656. this.form.status = response.data.status.toString();
  657. if (this.form.excludeTags!==''&&this.form.excludeTags!=null){
  658. this.excludeTags = this.form.excludeTags.split(",");
  659. }
  660. if (this.form.setting!=null){
  661. this.setting=JSON.parse(this.form.setting);
  662. }
  663. if(this.form.autoGroupLevel != null){
  664. this.form.autoGroupLevelArray = this.form.autoGroupLevel.split(",").map(Number);
  665. }
  666. if(this.form.qwUserIds != null){
  667. getQwUserByIds(this.form.qwUserIds).then(res => {
  668. this.companyQwUserList = res.data;
  669. })
  670. }
  671. listSopTemp({id:this.form.tempId}).then(response => {
  672. this.tempList = response.rows;
  673. });
  674. this.refreshData(this.form.corpId);
  675. this.title = "修改企微sop";
  676. });
  677. },
  678. // 表单重置
  679. reset() {
  680. this.form = {
  681. id: null,
  682. name: null,
  683. status: 1,
  684. sendType:2,
  685. type: 2,
  686. filterType:2,
  687. qwUserIds: null,
  688. autoGroupLevelArray:[],
  689. corpId: null,
  690. setting: null,
  691. createBy: null,
  692. createTime: null,
  693. autoSopTime:{},
  694. };
  695. this.resetForm("form");
  696. this.tags=[];
  697. this.excludeTags = null;
  698. },
  699. /** 重置按钮操作 */
  700. resetQuery() {
  701. this.resetForm("queryForm");
  702. this.handleQuery();
  703. },
  704. // 多选框选中数据
  705. handleSelectionChange(selection) {
  706. this.ids = selection.map(item => item.id)
  707. this.single = selection.length!==1
  708. this.multiple = !selection.length
  709. },
  710. /** 新增按钮操作 */
  711. handleAdd() {
  712. this.reset();
  713. this.open = true;
  714. this.setting=[]
  715. this.userSelectList=[]
  716. this.title = "添加企微sop";
  717. },
  718. formatDateTo24HourString(date) {
  719. let year = date.getFullYear();
  720. let month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份需要加 1 并补零
  721. let day = ('0' + date.getDate()).slice(-2); // 日需要补零
  722. let hours = ('0' + date.getHours()).slice(-2); // 小时需要补零
  723. let minutes = ('0' + date.getMinutes()).slice(-2); // 分钟需要补零
  724. let seconds = ('0' + date.getSeconds()).slice(-2); // 秒需要补零
  725. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  726. },
  727. /** 提交按钮 */
  728. submitForm() {
  729. this.$refs["form"].validate(valid => {
  730. if (valid) {
  731. if(this.userSelectList.length<=0){
  732. return this.$message("请选择员工")
  733. }
  734. this.form.qwUserIds = this.userSelectList.join(",");
  735. if (this.tags!=null && this.tags.length>0 ){
  736. this.form.tags=(this.tags).toString()
  737. }else {
  738. return this.$message.error("选择得标签不能为空!!请选择筛选的标签")
  739. }
  740. if (this.excludeTags!=null){
  741. this.form.excludeTags=(this.excludeTags).toString()
  742. }
  743. this.form.setting=JSON.stringify(this.setting)
  744. this.form.autoSopTime.updateTime=this.formatDateTo24HourString(new Date());
  745. this.form.autoSopTime=JSON.stringify(this.form.autoSopTime)
  746. if (this.form.id != null) {
  747. updateSop(this.form).then(response => {
  748. this.msgSuccess("修改成功");
  749. this.$store.dispatch("tagsView/delView", this.$route);
  750. // this.$router.replace('/qw/conversion/sop')
  751. window.location.replace('/qw/conversion/sop')
  752. this.reset();
  753. });
  754. } else {
  755. addSop(this.form).then(response => {
  756. this.msgSuccess("新增成功");
  757. this.$store.dispatch("tagsView/delView", this.$route);
  758. // this.$router.replace('/qw/conversion/sop')
  759. window.location.replace('/qw/conversion/sop')
  760. this.reset();
  761. });
  762. }
  763. }
  764. });
  765. },
  766. }
  767. };
  768. </script>
  769. <style scoped>
  770. .custom-input /deep/ .el-input__inner {
  771. height: 20px;
  772. padding: 0 4px;
  773. text-align:center;
  774. display: block;
  775. }
  776. .custom-input /deep/ .el-input__icon {
  777. line-height: 20px;
  778. }
  779. /* 弹窗固定高度 */
  780. .fixed-dialog {
  781. height: 500px; /* 固定高度 */
  782. }
  783. /* 内容区域滚动 */
  784. .fixed-dialog .el-dialog__body {
  785. height: calc(100% - 110px); /* 减去标题和底部区域的高度 */
  786. overflow-y: auto; /* 垂直滚动 */
  787. }
  788. </style>