addSopTempOld.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <template>
  2. <div class="app-container">
  3. <div style="margin: 30px;" v-if="this.form.sendType == 1 "> sop规则【企微接口】模板</div>
  4. <div style="margin: 30px;" v-if="this.form.sendType == 2 "> sop规则【AI插件】模板</div>
  5. <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 60px;">
  6. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  7. <el-form-item label="名称" prop="name">
  8. <el-input v-model="form.name" placeholder="请输入模板标题" />
  9. </el-form-item>
  10. <el-form-item label="状态">
  11. <el-radio-group v-model="form.status">
  12. <el-radio
  13. v-for="dict in statusOptions"
  14. :key="dict.dictValue"
  15. :label="dict.dictValue"
  16. >{{dict.dictLabel}}</el-radio>
  17. </el-radio-group>
  18. </el-form-item>
  19. <el-form-item label="间隔天数" prop="gap">
  20. <el-input-number v-model="form.gap" :min="1" label="间隔天数"></el-input-number>
  21. </el-form-item>
  22. <el-form-item label="排序" prop="sort">
  23. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  24. </el-form-item>
  25. <el-form-item label="规则" prop="setting">
  26. <el-timeline >
  27. <el-timeline-item :timestamp="'第'+(1+(form.gap*index))+'天'" :color="'#0bbd87'" placement="top" v-for="(item, index) in setting" style="margin-top: 10px;">
  28. <el-row>
  29. <el-col :span="22">
  30. <div style="background-color: #fbfbfb;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  31. <el-form :model="item" label-width="80px">
  32. <el-form-item label="内容名称" style="height: 50px;">
  33. <el-input v-model="item.name" placeholder="内容名称,仅内部可见" />
  34. </el-form-item>
  35. <el-form-item label="规则" >
  36. <div v-for="(content, contentIndex) in item.content" style="background-color: #fdfdfd;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  37. <el-row>
  38. <el-col el-col :span="22" >
  39. <el-form :model="content" label-width="70px">
  40. <el-form-item label="时间" prop="time" >
  41. <el-time-picker
  42. class="custom-input"
  43. v-model="content.time"
  44. value-format="HH:mm"
  45. format="HH:mm"
  46. :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
  47. placeholder="时间"
  48. style="width: 100px;height: 20px;" >
  49. </el-time-picker>
  50. </el-form-item>
  51. <el-form-item label="消息类别" >
  52. <el-radio-group v-model="content.type" @change="() => content.contentType = '1'" >
  53. <el-radio
  54. :label="1"
  55. >普通</el-radio>
  56. <el-radio
  57. :label="2"
  58. >课程</el-radio>
  59. <el-radio
  60. :label="3"
  61. >订单</el-radio>
  62. </el-radio-group>
  63. </el-form-item>
  64. <el-form-item label="课程" v-if="content.type == 2 ">
  65. <el-select v-model="content.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange(content,index,contentIndex)">
  66. <el-option
  67. v-for="dict in courseList"
  68. :key="dict.dictValue"
  69. :label="dict.dictLabel"
  70. :value="parseInt(dict.dictValue)"
  71. />
  72. </el-select>
  73. <el-select v-model="content.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange(content,index,contentIndex)" >
  74. <el-option
  75. v-for="dict in videoList[index][contentIndex]"
  76. :key="dict.dictValue"
  77. :label="dict.dictLabel"
  78. :value="parseInt(dict.dictValue)"
  79. />
  80. </el-select>
  81. <el-select v-model="content.courseType" placeholder="请选择消息类型" size="mini" style=" margin-right: 10px;">
  82. <el-option
  83. v-for="dict in sysFsSopWatchStatus"
  84. :key="dict.dictValue"
  85. :label="dict.dictLabel"
  86. :value="parseInt(dict.dictValue)"
  87. />
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item label="内容类别" >
  91. <!-- <div v-for="(list, setIndex) in content.setting ">-->
  92. <!-- <el-row>-->
  93. <!-- <el-col el-col :span="22" >-->
  94. <!-- -->
  95. <!-- </el-col>-->
  96. <!-- <el-col :span="1" :offset="1">-->
  97. <!-- <i class="el-icon-delete" @click="delContent(index,contentIndex)" style="margin-top: 20px;" v-if="item.content.length>1"></i>-->
  98. <!-- </el-col>-->
  99. <!-- </el-row>-->
  100. <!-- </div>-->
  101. <div v-if="form.sendType == 1 ">
  102. <el-radio-group v-model="content.contentType" >
  103. <el-radio :label="item.dictValue" v-for="item in sysQwSopContentType">{{item.dictLabel}}</el-radio>
  104. </el-radio-group>
  105. </div>
  106. <div v-if="form.sendType == 2 ">
  107. <div v-if="content.type == 2 ">
  108. <el-radio-group v-model="content.contentType" @change="handleContentTypeChange(content,index,contentIndex)">
  109. <el-radio :label="item.dictValue" v-for="item in sysQwSopSettingType">{{item.dictLabel}}</el-radio>
  110. </el-radio-group>
  111. </div>
  112. <div v-else>
  113. <el-radio-group v-model="content.contentType" @change="handleContentTypeChange(content,index,contentIndex)">
  114. <el-radio :label="item.dictValue" v-for="item in sysQwSopAiContentType">{{item.dictLabel}}</el-radio>
  115. </el-radio-group>
  116. </div>
  117. </div>
  118. </el-form-item>
  119. <el-form-item label="内容" >
  120. <el-input v-if="content.contentType == 1 " v-model="content.value" type="textarea" :rows="3" placeholder="内容" style="width: 90%;margin-top: 10px;"/>
  121. <ImageUpload v-if="content.contentType == 2 " v-model="content.imgUrl" type="image" :num="1" :width="150" :height="150" />
  122. <div v-if="content.contentType == 3 ">
  123. <el-card class="box-card">
  124. <el-form-item label="链接标题:" label-width="100px">
  125. <el-input v-model="content.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  126. </el-form-item>
  127. <el-form-item label="链接描述:" label-width="100px" >
  128. <el-input type="textarea" :rows="3" v-model="content.linkDescribe" placeholder="请输入链接描述" style="width: 90%;margin-top: 1%;"/>
  129. </el-form-item>
  130. <el-form-item label="链接封面:" label-width="100px">
  131. <ImageUpload v-model="content.linkImageUrl" type="image" :num="1" :width="150" :height="150" style="margin-top: 1%;" />
  132. </el-form-item>
  133. <div v-if="content.type!=2" style="margin-top: 1%">
  134. <el-form-item label="链接地址:" label-width="100px" >
  135. <el-input v-model="content.linkUrl" placeholder="请输入链接地址" style="width: 90%;"/>
  136. </el-form-item>
  137. </div>
  138. <div v-if="content.type==2">
  139. <el-form-item label="链接地址:" label-width="100px" >
  140. <el-tag type="warning" v-model="content.isBindUrl=1">选择的课程小节 即为卡片链接地址</el-tag>
  141. </el-form-item>
  142. </div>
  143. </el-card>
  144. </div>
  145. <div v-if="content.contentType == 5 ">
  146. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  147. <el-upload
  148. v-model="content.fileUrl"
  149. class="avatar-uploader"
  150. :action="uploadUrl"
  151. :show-file-list="false"
  152. :on-success="(res, file) => handleAvatarSuccessFile(res, file, content)"
  153. :before-upload="beforeAvatarUploadFile">
  154. <i class="el-icon-plus avatar-uploader-icon"></i>
  155. </el-upload>
  156. <el-link v-if="content.fileUrl" type="primary" :href="downloadUrl(content.fileUrl)" download>
  157. {{content.fileUrl}}
  158. </el-link>
  159. </el-form-item>
  160. </div>
  161. <div v-if="content.contentType == 6 ">
  162. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  163. <el-upload
  164. v-model="content.videoUrl"
  165. class="avatar-uploader"
  166. :action="uploadUrl"
  167. :show-file-list="false"
  168. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, content)"
  169. :before-upload="beforeAvatarUploadVideo">
  170. <i class="el-icon-plus avatar-uploader-icon"></i>
  171. </el-upload>
  172. <video v-if="content.videoUrl"
  173. :src="content.videoUrl"
  174. controls style="width: 200px;height: 100px">
  175. </video>
  176. </el-form-item>
  177. </div>
  178. <div v-if="content.contentType == 7 ">
  179. <el-form-item label="上传语音:" prop="videoUrl" label-width="100px">
  180. <el-upload
  181. v-model="content.voiceUrl"
  182. class="avatar-uploader"
  183. :action="uploadUrl"
  184. :show-file-list="false"
  185. :on-success="(res, file) => handleAvatarSuccessVoice(res, file, content)"
  186. :before-upload="beforeAvatarUploadVoice">
  187. <i class="el-icon-plus avatar-uploader-icon"></i>
  188. </el-upload>
  189. <audio v-if="content.voiceUrl"
  190. :src="content.voiceUrl"
  191. controls style="width: 300px;height: 50px">
  192. </audio >
  193. </el-form-item>
  194. </div>
  195. </el-form-item>
  196. <el-form-item label="添加短链" v-if="content.type == 2 && content.contentType == 1 " >
  197. <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark" :disabled="!!content.videoId">
  198. <el-switch
  199. v-model="content.isBindUrl"
  200. :disabled="!content.videoId"
  201. active-color="#13ce66"
  202. inactive-color="#DCDFE6"
  203. active-value="1"
  204. inactive-value="2">
  205. </el-switch>
  206. </el-tooltip>
  207. <span v-if="content.isBindUrl == '1'" style="margin-left: 10px; color: #13ce66">添加URL</span>
  208. <span v-if="content.isBindUrl == '2'" style="margin-left: 10px; color: #b1b4ba">不加URL</span>
  209. </el-form-item>
  210. <el-form-item label="课节过期时间" v-if="content.type == 2 && content.isBindUrl == '1' && content.contentType != 2 && content.contentType != 5 && content.contentType != 6 " style="margin-top: 1%">
  211. <el-row>
  212. <el-input-number v-model="content.expiresDays" :min="0" :max="100" ></el-input-number>
  213. (天)
  214. </el-row>
  215. <el-row>
  216. <span class="tip">填写0或不填时,默认为系统配置的默认时间</span>
  217. </el-row>
  218. </el-form-item>
  219. </el-form>
  220. </el-col>
  221. <el-col :span="1" :offset="1">
  222. <i class="el-icon-delete" @click="delContent(index,contentIndex)" style="margin-top: 20px;" v-if="item.content.length>1"></i>
  223. </el-col>
  224. </el-row>
  225. </div>
  226. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addContent(index)'>添加规则</el-link>
  227. </el-form-item>
  228. </el-form>
  229. </div>
  230. </el-col>
  231. <el-col :span="1" :offset="1">
  232. <i class="el-icon-delete-solid" @click="delSetting(index)" v-if="setting.length>1"></i>
  233. </el-col>
  234. </el-row>
  235. </el-timeline-item>
  236. </el-timeline>
  237. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetting()'>添加天数</el-link>
  238. </el-form-item>
  239. </el-form>
  240. <div slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end;">
  241. <el-button type="primary" @click="submitForm">确 定</el-button>
  242. <el-button @click="cancel">取 消</el-button>
  243. </div>
  244. </div>
  245. </div>
  246. </template>
  247. <script>
  248. import { listSopTemp, getSopTemp, delSopTemp, addSopTemp, updateSopTemp, exportSopTemp } from "@/api/qw/sopTemp";
  249. import { courseList,videoList } from "@/api/qw/sop";
  250. import ImageUpload from "@/views/qw/sop/ImageUpload";
  251. import FriendMaterial from "@/views/qw/friendMaterial/index.vue";
  252. export default {
  253. name: "SopTemp",
  254. components: { ImageUpload,FriendMaterial},
  255. data() {
  256. return {
  257. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  258. // 遮罩层
  259. loading: true,
  260. // 导出遮罩层
  261. exportLoading: false,
  262. // 选中数组
  263. ids: [],
  264. sysFsSopWatchStatus: [],
  265. //消息内容类型 企微版
  266. sysQwSopContentType:[],
  267. //插件版
  268. sysQwSopAiContentType:[],
  269. //类别
  270. sysQwSopSettingType:[],
  271. courseList:[],
  272. videoList:[],
  273. // 非单个禁用
  274. single: true,
  275. // 非多个禁用
  276. multiple: true,
  277. // 显示搜索条件
  278. showSearch: true,
  279. // 总条数
  280. total: 0,
  281. // sop模板表格数据
  282. setting: [],
  283. // 弹出层标题
  284. title: "",
  285. // 是否显示弹出层
  286. open: false,
  287. // 状态字典
  288. statusOptions: [],
  289. // 查询参数
  290. form: {
  291. name: null,
  292. setting: null,
  293. status: "1",
  294. sort: 1,
  295. companyId: null,
  296. gap:1,
  297. },
  298. // 表单校验
  299. rules: {
  300. name: [
  301. { required: true, message: '名称不能为空', trigger: 'blur' }
  302. ],
  303. status: [
  304. { required: true, message: '状态不能为空', trigger: 'blur' }
  305. ],
  306. sort: [
  307. { required: true, message: '排序不能为空', trigger: 'blur' }
  308. ],
  309. gap: [
  310. { required: true, message: '间隔天数不能为空', trigger: 'blur' }
  311. ],
  312. },
  313. contentRules:{
  314. time:[{ required: true, message: '时间不能为空', trigger: 'blur' }],
  315. }
  316. };
  317. },
  318. created() {
  319. this.getDicts("sys_company_status").then(response => {
  320. this.statusOptions = response.data;
  321. });
  322. courseList().then(response => {
  323. this.courseList = response.list;
  324. });
  325. this.getDicts("sys_fs_sop_watch_status").then(response => {
  326. this.sysFsSopWatchStatus = response.data;
  327. });
  328. this.getDicts("sys_qwSopAi_contentType").then(response => {
  329. this.sysQwSopAiContentType = response.data;
  330. });
  331. this.getDicts("sys_qwSop_contentType").then(response => {
  332. this.sysQwSopContentType = response.data;
  333. });
  334. this.getDicts("sys_qwSop_settingType").then(response => {
  335. this.sysQwSopSettingType = response.data;
  336. });
  337. this.form.sendType= this.$route.params && this.$route.params.command;
  338. setTimeout(() => {
  339. this.getList();
  340. }, 200);
  341. },
  342. methods: {
  343. addContent(index){
  344. if (this.setting[index].content.length>0 && this.form.sendType==1){
  345. return this.$message.error("因为企微接口限制,企微模板一天只能设置一条消息~")
  346. }else {
  347. this.setting[index].content.push({type:1,contentType:'1'})
  348. this.videoList[index].push([])
  349. }
  350. },
  351. delContent(index,contentIndex){
  352. this.setting[index].content.splice(contentIndex,1)
  353. this.videoList[index].splice(contentIndex,1)
  354. },
  355. addSetting(){
  356. this.setting.push({name:null,content:[{type:1,contentType:'1'}]})
  357. this.videoList.push([])
  358. },
  359. delSetting(index){
  360. this.setting.splice(index,1)
  361. this.videoList.splice(index,1)
  362. },
  363. //上传文件
  364. handleAvatarSuccessFile(res, file, content) {
  365. if (res.code === 200) {
  366. // 使用 $set 确保响应式更新
  367. this.$set(content, 'fileUrl', res.url);
  368. } else {
  369. this.msgError(res.msg);
  370. }
  371. },
  372. beforeAvatarUploadFile(file){
  373. const isLt1M = file.size / 1024 / 1024 < 30;
  374. if (!isLt1M) {
  375. this.$message.error('上传大小不能超过 30MB!');
  376. }
  377. return isLt1M;
  378. },
  379. //下载文件
  380. downloadUrl(materialUrl) {
  381. // 直接返回文件 URL
  382. return materialUrl;
  383. },
  384. handleAvatarSuccessVideo(res, file, content) {
  385. if(res.code==200){
  386. // 使用 $set 确保响应式更新
  387. this.$set(content, 'videoUrl', res.url);
  388. }
  389. else{
  390. this.msgError(res.msg);
  391. }
  392. },
  393. handleAvatarSuccessVoice(res, file, content){
  394. if(res.code==200){
  395. // 使用 $set 确保响应式更新
  396. this.$set(content, 'voiceUrl', res.url);
  397. }
  398. else{
  399. this.msgError(res.msg);
  400. }
  401. },
  402. beforeAvatarUploadVideo(file){
  403. const isLt30M = file.size / 1024 / 1024 < 50;
  404. const isMP4 = file.type === 'video/mp4';
  405. if (!isMP4) {
  406. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  407. return false;
  408. }
  409. if (!isLt30M) {
  410. this.$message.error('上传大小不能超过 50MB!');
  411. return false;
  412. }
  413. return true;
  414. },
  415. beforeAvatarUploadVoice(file){
  416. const isLt10M = file.size / 1024 / 1024 < 10; // 假设语音文件大小限制为10MB
  417. const isVoiceType = ['audio/mp3'].includes(file.type); // 支持的语音文件类型
  418. if (!isVoiceType) {
  419. this.$message.error('仅支持上传 MP3 格式的语音文件!');
  420. return false;
  421. }
  422. if (!isLt10M) {
  423. this.$message.error('上传大小不能超过 10MB!');
  424. return false;
  425. }
  426. return true;
  427. },
  428. handleClosegroupUser(list){
  429. const index = this.userSelectList.findIndex(t => t === list);
  430. if (index !== -1) {
  431. this.userSelectList.splice(index, 1);
  432. }
  433. },
  434. courseChange(content,index,countIndex){
  435. this.$set(content, 'videoId', null);
  436. //如果是链接的才上
  437. if (content.contentType==3 && content.type==2 && content.courseId!=null){
  438. // 查找选中的课程对应的 label
  439. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
  440. //响应式直接给链接的标题/封面上值
  441. if (selectedCourse) {
  442. this.$set(content, 'linkTitle', selectedCourse.dictLabel);
  443. this.$set(content, 'linkImageUrl', selectedCourse.dictImgUrl);
  444. }
  445. }
  446. videoList(content.courseId).then(response => {
  447. this.videoList[index].splice(countIndex, 1, response.list);
  448. });
  449. },
  450. handleContentTypeChange(content,index,countIndex){
  451. //如果是链接的才上
  452. if (content.contentType==3 && content.type==2 ) {
  453. if (content.courseId!=null) {
  454. // 查找选中的课程对应的 label
  455. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
  456. //响应式直接给链接的标题/封面上值
  457. if (selectedCourse) {
  458. this.$set(content, 'linkTitle', selectedCourse.dictLabel);
  459. this.$set(content, 'linkImageUrl', selectedCourse.dictImgUrl);
  460. }
  461. }
  462. if (content.videoId!=null){
  463. // 查找选中的课程对应的 label
  464. const selectedVideo = this.videoList[index][countIndex].find(course => parseInt(course.dictValue) === content.videoId);
  465. //响应式直接给链接的描述上值
  466. if (selectedVideo) {
  467. this.$set(content, 'linkDescribe', selectedVideo.dictLabel);
  468. }
  469. }
  470. }
  471. },
  472. videoIdChange(content,index,countIndex){
  473. //选择了课程小节则 默认绑上
  474. this.$set(content,'isBindUrl','1');
  475. //如果是链接的才上
  476. if (content.contentType==3 && content.type==2 && content.videoId!=null ) {
  477. // 查找选中的课程对应的 label
  478. const selectedVideo = this.videoList[index][countIndex].find(course => parseInt(course.dictValue) === content.videoId);
  479. //响应式直接给链接的描述上值
  480. if (selectedVideo) {
  481. this.$set(content, 'linkDescribe', selectedVideo.dictLabel);
  482. }
  483. }
  484. },
  485. /** 查询sop模板列表 */
  486. getList() {
  487. this.loading = true;
  488. listSopTemp(this.queryParams).then(response => {
  489. this.sopTempList = response.rows;
  490. this.total = response.total;
  491. this.loading = false;
  492. });
  493. },
  494. // 取消按钮
  495. cancel() {
  496. this.$store.dispatch("tagsView/delView", this.$route);
  497. this.$router.replace('/qw/conversion/sopTemp')
  498. this.reset();
  499. },
  500. // 表单重置
  501. reset() {
  502. this.form = {
  503. id: null,
  504. name: null,
  505. setting: null,
  506. status: "0",
  507. sort: null,
  508. createTime: null,
  509. createBy: null,
  510. companyId: null,
  511. };
  512. this.resetForm("form");
  513. },
  514. /** 搜索按钮操作 */
  515. handleQuery() {
  516. this.queryParams.pageNum = 1;
  517. this.getList();
  518. },
  519. /** 重置按钮操作 */
  520. resetQuery() {
  521. this.resetForm("queryForm");
  522. this.handleQuery();
  523. },
  524. // 多选框选中数据
  525. handleSelectionChange(selection) {
  526. this.ids = selection.map(item => item.id)
  527. this.single = selection.length!==1
  528. this.multiple = !selection.length
  529. },
  530. /** 新增按钮操作 */
  531. handleAdd() {
  532. this.reset();
  533. this.open = true;
  534. this.title = "添加sop模板";
  535. },
  536. /** 修改按钮操作 */
  537. handleUpdate(row) {
  538. this.reset();
  539. const id = row.id || this.ids
  540. getSopTemp(id).then(response => {
  541. this.form = response.data;
  542. this.open = true;
  543. this.title = "修改sop模板";
  544. });
  545. },
  546. /** 提交按钮 */
  547. submitForm() {
  548. this.$refs["form"].validate(valid => {
  549. if (valid) {
  550. this.form.setting=JSON.stringify(this.setting)
  551. if(this.setting.length<=0){
  552. return this.$message("请添加规则")
  553. }
  554. for (let i = 0; i < this.setting.length; i++) {
  555. for (let j = 0; j < this.setting[i].content.length; j++) {
  556. if(this.setting[i].name==null||this.setting[i].name==""){
  557. return this.$message.error("内容名称不能为空")
  558. }
  559. if(this.setting[i].content[j].time==null||this.setting[i].content[j].time==""){
  560. return this.$message.error("时间不能为空")
  561. }
  562. if (this.setting[i].content[j].contentType==1 && (this.setting[i].content[j].value==null|| this.setting[i].content[j].value=="")){
  563. return this.$message.error("内容不能为空")
  564. }
  565. if (this.setting[i].content[j].contentType==2 && (this.setting[i].content[j].imgUrl==null|| this.setting[i].content[j].imgUrl=="")){
  566. return this.$message.error("图片不能为空")
  567. }
  568. if (this.setting[i].content[j].contentType==3 && (this.setting[i].content[j].linkTitle==null|| this.setting[i].content[j].linkTitle=="")){
  569. return this.$message.error("链接标题不能为空")
  570. }
  571. if (this.setting[i].content[j].contentType==3 && (this.setting[i].content[j].linkDescribe==null|| this.setting[i].content[j].linkDescribe=="")){
  572. return this.$message.error("链接描述不能为空")
  573. }
  574. if (this.setting[i].content[j].contentType==3 && (this.setting[i].content[j].linkImageUrl==null|| this.setting[i].content[j].linkImageUrl=="")){
  575. return this.$message.error("链接图片不能为空")
  576. }
  577. if (this.setting[i].content[j].contentType==3 && this.setting[i].content[j].type==1 && (this.setting[i].content[j].linkUrl==null|| this.setting[i].content[j].linkUrl=="")){
  578. return this.$message.error("链接地址不能为空")
  579. }
  580. if (this.setting[i].content[j].contentType==5 && (this.setting[i].content[j].fileUrl==null|| this.setting[i].content[j].fileUrl=="")){
  581. return this.$message.error("文件不能为空")
  582. }
  583. if (this.setting[i].content[j].contentType==6 && (this.setting[i].content[j].videoUrl==null|| this.setting[i].content[j].videoUrl=="")){
  584. return this.$message.error("视频不能为空")
  585. }
  586. if (this.setting[i].content[j].contentType==7 && (this.setting[i].content[j].voiceUrl==null|| this.setting[i].content[j].voiceUrl=="")){
  587. return this.$message.error("语音不能为空")
  588. }
  589. }
  590. }
  591. if (this.form.id != null) {
  592. updateSopTemp(this.form).then(response => {
  593. this.msgSuccess("修改成功");
  594. this.$store.dispatch("tagsView/delView", this.$route);
  595. // this.$router.replace('/qw/conversion/sopTemp')
  596. window.location.replace('/qw/conversion/sopTemp')
  597. this.reset();
  598. });
  599. }
  600. else {
  601. addSopTemp(this.form).then(response => {
  602. this.msgSuccess("新增成功");
  603. this.$store.dispatch("tagsView/delView", this.$route);
  604. // this.$router.replace('/qw/conversion/sopTemp')
  605. window.location.replace('/qw/conversion/sopTemp')
  606. this.reset();
  607. });
  608. }
  609. }
  610. });
  611. },
  612. /** 删除按钮操作 */
  613. handleDelete(row) {
  614. const ids = row.id || this.ids;
  615. this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
  616. confirmButtonText: "确定",
  617. cancelButtonText: "取消",
  618. type: "warning"
  619. }).then(function() {
  620. return delSopTemp(ids);
  621. }).then(() => {
  622. this.getList();
  623. this.msgSuccess("删除成功");
  624. }).catch(() => {});
  625. },
  626. /** 导出按钮操作 */
  627. handleExport() {
  628. const queryParams = this.queryParams;
  629. this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
  630. confirmButtonText: "确定",
  631. cancelButtonText: "取消",
  632. type: "warning"
  633. }).then(() => {
  634. this.exportLoading = true;
  635. return exportSopTemp(queryParams);
  636. }).then(response => {
  637. this.download(response.msg);
  638. this.exportLoading = false;
  639. }).catch(() => {});
  640. }
  641. }
  642. };
  643. </script>
  644. <style scoped>
  645. .custom-input /deep/ .el-input__inner {
  646. height: 20px;
  647. text-align:center;
  648. }
  649. .custom-input /deep/ .el-input__icon {
  650. line-height: 10px;
  651. }
  652. </style>