addAiChatTemp.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div class="app-container">
  3. <div style="margin: 30px;">sop规则【新客对话】模板</div>
  4. <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 60px;">
  5. <el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
  6. <el-form-item label="名称" prop="name">
  7. <el-input v-model="form.name" placeholder="请输入模板标题"/>
  8. </el-form-item>
  9. <el-form-item label="状态">
  10. <el-radio-group v-model="form.status">
  11. <el-radio
  12. v-for="dict in statusOptions"
  13. :key="dict.dictValue"
  14. :label="dict.dictValue"
  15. >{{ dict.dictLabel }}
  16. </el-radio>
  17. </el-radio-group>
  18. </el-form-item>
  19. <el-form-item label="推送方式">
  20. <el-radio-group v-model="form.sendType">
  21. <el-radio
  22. v-for="dict in sysQwSopType.filter(item => parseInt(item.dictValue) === 4)"
  23. :key="dict.dictValue"
  24. :label="parseInt(dict.dictValue)"
  25. >{{ dict.dictLabel }}
  26. </el-radio>
  27. </el-radio-group>
  28. </el-form-item>
  29. <!-- <el-form-item label="间隔天数" prop="gap">
  30. <el-input-number v-model="form.gap" :min="1" label="间隔天数"></el-input-number>
  31. </el-form-item> -->
  32. <el-form-item label="排序" prop="sort">
  33. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  34. </el-form-item>
  35. <el-form-item label="规则" prop="setting">
  36. <el-timeline>
  37. <el-timeline-item
  38. :timestamp="'第'+(1+(form.gap*index))+'天'"
  39. :color="'#0bbd87'"
  40. placement="top"
  41. v-for="(item, index) in setting"
  42. :key="index"
  43. style="margin-top: 10px;">
  44. <el-row>
  45. <el-col :span="22">
  46. <div style="background-color: #fbfbfb;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  47. <el-form :model="item" label-width="80px">
  48. <el-form-item label="规则">
  49. <div v-for="(content, contentIndex) in item.content"
  50. :key="contentIndex"
  51. style="background-color: #fdfdfd;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  52. <el-row>
  53. <el-col :span="22">
  54. <el-form :model="content" label-width="70px">
  55. <!-- 第一天不显示时间选择 -->
  56. <el-form-item label="时间" prop="time" v-if="index > 0">
  57. <el-time-picker
  58. class="custom-input"
  59. v-model="content.time"
  60. value-format="HH:mm"
  61. format="HH:mm"
  62. :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
  63. placeholder="时间"
  64. style="width: 100px;height: 20px;">
  65. </el-time-picker>
  66. </el-form-item>
  67. <div v-for="(setList, setIndex) in content.setting"
  68. :key="setIndex"
  69. style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  70. <el-row>
  71. <el-col :span="22">
  72. <el-form :model="setList" label-width="70px">
  73. <el-form-item label="添加客服" prop="intervalTime" style="margin: 2%">
  74. <el-input-number
  75. v-model="setList.intervalTime"
  76. :min="1"
  77. :max="1440"
  78. style="width:100;margin-top: 10px;"
  79. >
  80. </el-input-number>
  81. <span class="tip">单位:分钟,最大1440分钟(24小时)</span>
  82. </el-form-item>
  83. <el-form-item label="内容" style="margin: 2%">
  84. <el-input
  85. v-model="setList.value"
  86. type="textarea"
  87. :rows="3"
  88. placeholder="内容"
  89. style="width: 90%;margin-top: 10px;"/>
  90. </el-form-item>
  91. <el-form-item label="交流状态" style="margin: 2%">
  92. <el-select v-model="setList.talkType" placeholder="更改交流状态" size="mini"
  93. style=" margin-right: 10px;" clearable>
  94. <el-option label="非首次交流" value="非首次交流"></el-option>
  95. <el-option label="首次交流1" value="首次交流1"></el-option>
  96. <el-option label="首次交流2" value="首次交流2"></el-option>
  97. <el-option label="交流状态1" value="交流状态1"></el-option>
  98. <el-option label="交流状态2" value="交流状态2"></el-option>
  99. <el-option label="交流状态3" value="交流状态3"></el-option>
  100. </el-select>
  101. </el-form-item>
  102. </el-form>
  103. </el-col>
  104. <el-col :span="1" :offset="1">
  105. <i class="el-icon-delete"
  106. @click="delSetList(index,contentIndex,setIndex)"
  107. style="margin-top: 20px;"
  108. v-if="content.setting.length>1"></i>
  109. </el-col>
  110. </el-row>
  111. </div>
  112. <el-link type="primary"
  113. class="el-icon-plus"
  114. :underline="false"
  115. @click='addSetList(contentIndex,item.content)'>添加内容
  116. </el-link>
  117. </el-form>
  118. </el-col>
  119. <el-col :span="1" :offset="1">
  120. <i class="el-icon-delete"
  121. @click="delContent(index,contentIndex)"
  122. style="margin-top: 20px;"
  123. v-if="item.content.length>1"></i>
  124. </el-col>
  125. </el-row>
  126. </div>
  127. <el-link type="primary"
  128. v-if="index > 0"
  129. class="el-icon-plus"
  130. :underline="false"
  131. @click='addContent(index)'>添加规则
  132. </el-link>
  133. </el-form-item>
  134. </el-form>
  135. </div>
  136. </el-col>
  137. <el-col :span="1" :offset="1">
  138. <i class="el-icon-delete"
  139. @click="delSetting(index)"
  140. v-if="setting.length>1"></i>
  141. </el-col>
  142. </el-row>
  143. </el-timeline-item>
  144. </el-timeline>
  145. <!-- <el-link type="primary"
  146. class="el-icon-plus"
  147. :underline="false"
  148. @click='addSetting()'>添加天数</el-link> -->
  149. </el-form-item>
  150. </el-form>
  151. <div slot="footer" class="dialog-footer" style="float: right;">
  152. <el-button type="primary" @click="submitForm">确 定</el-button>
  153. <el-button @click="cancel">取 消</el-button>
  154. </div>
  155. </div>
  156. </div>
  157. </template>
  158. <script>
  159. import {addSopTemp} from "@/api/qw/sopTemp";
  160. export default {
  161. name: "AddAiChatTemp",
  162. data() {
  163. return {
  164. // 状态字典
  165. statusOptions: [],
  166. // 添加推送方式字典
  167. sysQwSopType: [],
  168. // 表单数据
  169. form: {
  170. name: null,
  171. setting: null,
  172. status: "1",
  173. sort: 1,
  174. gap: 1,
  175. sendType: 4, // AI对话类型,固定值
  176. },
  177. // 规则设置
  178. setting: [],
  179. // 表单校验
  180. rules: {
  181. name: [
  182. {required: true, message: '名称不能为空', trigger: 'blur'}
  183. ],
  184. status: [
  185. {required: true, message: '状态不能为空', trigger: 'blur'}
  186. ],
  187. sort: [
  188. {required: true, message: '排序不能为空', trigger: 'blur'}
  189. ],
  190. gap: [
  191. {required: true, message: '间隔天数不能为空', trigger: 'blur'}
  192. ]
  193. }
  194. };
  195. },
  196. created() {
  197. this.getDicts("sys_company_status").then(response => {
  198. this.statusOptions = response.data;
  199. });
  200. // 获取推送方式字典
  201. this.getDicts("sys_qw_sop_type").then(response => {
  202. this.sysQwSopType = response.data;
  203. });
  204. this.getList();
  205. },
  206. methods: {
  207. getList() {
  208. this.setting.push({
  209. name: null,
  210. content: [{
  211. type: 1,
  212. contentType: '1',
  213. setting: [{
  214. intervalTime: 5,
  215. contentType: '1',
  216. value: ""
  217. }]
  218. }]
  219. });
  220. },
  221. addSetList(contentIndex, content) {
  222. content[contentIndex].setting.push({
  223. intervalTime: 5,
  224. contentType: '1',
  225. value: ""
  226. });
  227. },
  228. delSetList(index, contentIndex, setIndex) {
  229. this.setting[index].content[contentIndex].setting.splice(setIndex, 1);
  230. },
  231. addContent(index) {
  232. this.setting[index].content.push({
  233. type: 1,
  234. contentType: '1',
  235. // 默认5分钟
  236. setting: [{
  237. intervalTime: 5,
  238. contentType: '1',
  239. value: ""
  240. }]
  241. });
  242. },
  243. delContent(index, contentIndex) {
  244. this.setting[index].content.splice(contentIndex, 1);
  245. },
  246. addSetting() {
  247. this.setting.push({
  248. name: null,
  249. content: [{
  250. type: 1,
  251. contentType: '1',
  252. setting: [{
  253. intervalTime: 5, // 默认5分钟
  254. contentType: '1',
  255. value: ""
  256. }]
  257. }]
  258. });
  259. },
  260. delSetting(index) {
  261. this.setting.splice(index, 1);
  262. },
  263. submitForm() {
  264. this.$refs["formRef"].validate(valid => {
  265. if (valid) {
  266. // 验证内容
  267. for (let day of this.setting) {
  268. for (let content of day.content) {
  269. if (content.time === undefined && this.setting.indexOf(day) > 0) {
  270. return this.$message.error("时间不能为空");
  271. }
  272. for (let set of content.setting) {
  273. if (!set.intervalTime) {
  274. return this.$message.error("间隔时间不能为空");
  275. }
  276. if (!set.value) {
  277. return this.$message.error("内容不能为空");
  278. }
  279. }
  280. }
  281. }
  282. this.form.setting = JSON.stringify(this.setting);
  283. addSopTemp(this.form).then(response => {
  284. this.$message.success("新增成功");
  285. window.location.replace('/qw/conversion/sopTemp')
  286. this.reset();
  287. });
  288. }
  289. });
  290. },
  291. cancel() {
  292. this.$router.push('/qw/conversion/sopTemp');
  293. }
  294. }
  295. };
  296. </script>
  297. <style scoped>
  298. .custom-input /deep/ .el-input__inner {
  299. height: 20px;
  300. text-align: center;
  301. }
  302. .custom-input /deep/ .el-input__icon {
  303. line-height: 10px;
  304. }
  305. .tip {
  306. color: #909399;
  307. font-size: 12px;
  308. margin-left: 10px;
  309. }
  310. </style>