| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193 |
- <template>
- <div class="app-container">
- <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==1 "> sop规则【修改企微接口】模板</div>
- <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==2 "> sop规则【复制企微接口】模板</div>
- <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==3 "> sop规则【查看企微接口】模板</div>
- <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==1 "> sop规则【修改群发助手】模板</div>
- <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==2 "> sop规则【复制群发助手】模板</div>
- <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==3 "> sop规则【查看群发助手】模板</div>
- <div style="margin: 30px;">模板编号:【{{ this.form.id }}】</div>
- <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 60px;">
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-form-item label="名称" prop="name">
- {{ form.name }}
- </el-form-item>
- <el-form-item label="状态">
- <el-tag v-for="dict in statusOptions" v-if="dict.dictValue == form.status">{{ dict.dictLabel }}</el-tag>
- </el-form-item>
- <el-form-item label="间隔天数" prop="gap">
- {{ form.gap }}天
- </el-form-item>
- <el-form-item label="规则" prop="setting">
- <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetting()'
- v-if="form.sendType != 4 && formType != 3 && roles.includes('add_sop_temp_day')">添加天数
- </el-link>
- <el-link type="primary" class="el-icon-sort" :underline="false" @click='openUpdateDaySorts()'
- style="margin-left: 20px"
- v-if="form.sendType != 4 && formType != 3">修改天数排序
- </el-link>
- <el-link type="primary" class="el-icon-sort" :underline="false" @click='openUpdateSorts()'
- style="margin-left: 20px"
- v-if="form.sendType != 4 && formType != 3">修改规则排序
- </el-link>
- <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetting()'
- v-if="form.sendType == 4 && (formType != 3 && setting.length < 1) && roles.includes('add_sop_temp_day')">添加天数
- </el-link>
- <el-tabs v-model="tabIndex" type="card" @tab-remove="delSetting" v-if="setting && setting.length > 0"
- :before-leave="leave" @tab-click="tabClick">
- <el-tab-pane v-for="(item, index) in setting" :closable="formType != 3 && roles.includes('del_sop_temp_day')" :key="index" :name="index + ''">
- <el-badge slot="label" :is-dot="!item.id" class="item" style="display: inline-block">
- <span>{{ '第' + item.dayNum + '天' }}</span>
- </el-badge>
- <el-row v-loading="loading">
- <el-col :span="22">
- <div
- style="background-color: #fbfbfb;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
- <el-form :model="item" label-width="80px">
- <el-form-item v-if="form.sendType != 4" label="内容名称" style="height: 50px;">
- <el-input :disabled="formType == 3" v-model="item.name"
- placeholder="内容名称,仅内部可见"/>
- </el-form-item>
- <el-form-item label="课程" v-if="form.sendType == 11 && item.content && item.content.length > 0" required>
- <el-select :disabled="((formType == 3 || form.sendType == 11) && item.id != null) || !roles.includes('update_sop_temp_scourse')" v-model="item.content[0].courseId"
- placeholder="请选择课程" style=" margin-right: 10px;" size="mini" remote
- filterable
- @change="courseChangeUpdate(item.content[0], index, 0)">
- <el-option
- v-for="dict in courseList"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- <el-select :disabled="((formType == 3 || form.sendType == 11) && item.id != null) || !roles.includes('update_sop_temp_scourse')" v-model="item.content[0].videoId"
- placeholder="请选择小节" size="mini" style=" margin-right: 10px;" remote
- filterable
- @change="videoIdChange(item.content[0],index,0)">
- <el-option
- v-for="dict in videoList[0]"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="规则">
- <div v-for="(content, contentIndex) in item.content" :key="contentIndex"
- style="background-color: #fdfdfd;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
- <el-row>
- <el-col el-col :span="22">
- <el-form :model="content" label-width="70px">
- <div v-if="item.dayNum==1">
- <el-form-item label="时间" v-if="form.sendType != 4">
- <el-time-picker
- :disabled="formType == 3 || !roles.includes('update_sop_temp_time')"
- class="custom-input"
- v-model="content.time"
- value-format="HH:mm"
- format="HH:mm"
- :picker-options="{ selectableRange: ['01:00:00 - 01:59:00','05:00:00 - 23:59:59'] }"
- placeholder="时间"
- style="width: 100px;height: 20px;">
- </el-time-picker>
- </el-form-item>
- </div>
- <div v-else>
- <el-form-item label="时间" v-if="form.sendType != 4">
- <el-time-picker
- :disabled="formType == 3 || !roles.includes('update_sop_temp_time')"
- class="custom-input"
- v-model="content.time"
- :picker-options="{ selectableRange: ['00:01:00 - 00:59:00','05:00:00 - 23:59:59']}"
- value-format="HH:mm"
- format="HH:mm"
- placeholder="时间"
- style="width: 100px;height: 20px;">
- </el-time-picker>
- </el-form-item>
- </div>
- <el-form-item label="官方群发" v-if="contentIndex==0 && content.type==2 && form.sendType != 4">
- <el-switch
- v-model="content.isOfficial"
- active-color="#13ce66"
- inactive-color="#DCDFE6"
- active-value="1"
- inactive-value="0">
- </el-switch>
- <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px">
- <i class="el-icon-info"></i>
- 请注意:官方群发 【第1天】 只能设置1点-1点30 的时间,【其他天数时间】 只能设置0点-0点30。此处仅为生成发送记录时间,实际发送可由 销售在公司规定的 【暂早上8点(前!!)】,在企业微信的【群发助手】处点击发送
- </div>
- </el-form-item>
- <el-form-item label="是否@所有人" v-if="form.sendType != 4">
- <el-switch
- v-model="content.isAtAll"
- active-color="#13ce66"
- inactive-color="#DCDFE6"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- <div
- style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px">
- <i class="el-icon-info"></i>
- 开启后将在群发消息时@所有人(默认关闭)
- </div>
- </el-form-item>
- <el-form-item label="消息类型" v-if="form.sendType != 4">
- <el-select :disabled="formType == 3" v-model="content.courseType"
- placeholder="请选择消息类型" size="mini"
- style=" margin-right: 10px;" v-if="content.type != 4 ">
- <el-option
- v-for="dict in sysFsSopWatchStatus"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="Number(dict.dictValue)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="消息类别" v-if="form.sendType != 4 && form.sendType != 5">
- <el-radio-group v-model="content.type"
- :disabled="formType == 3 || content.isOfficial === '1'"
- @change="updateHtml(() => content.contentType = '1',content)">
- <el-radio :label="1">普通</el-radio>
- <el-radio :label="2">课程</el-radio>
- <el-radio :label="4">AI触达</el-radio>
- <el-radio :label="5">打标签</el-radio>
- <el-radio :label="20">直播间</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="直播间" v-if="content.type == 20">
- <el-select v-model="content.liveId"
- placeholder="请选择直播间" size="mini"
- @change="liveChangeContent(content)" >
- <el-option
- v-for="dict in liveList"
- :key="dict.liveId"
- :label="dict.liveName"
- :value="dict.liveId"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="课程" v-if="content.type == 2 && form.sendType != 5" required>
- <el-select :disabled="formType == 3 || form.sendType == 11 || !roles.includes('edit_sop_temp_content')" v-model="content.courseId"
- placeholder="请选择课程" style=" margin-right: 10px;" size="mini" remote
- filterable
- @change="courseChangeUpdate(content,index,contentIndex)">
- <el-option
- v-for="dict in courseList"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- <el-select :disabled="formType == 3 || form.sendType == 11 || !roles.includes('edit_sop_temp_content')" v-model="content.videoId"
- placeholder="请选择小节" size="mini" style=" margin-right: 10px;" remote
- filterable
- @change="videoIdChange(content,index,contentIndex)">
- <el-option
- v-for="dict in videoList[contentIndex]"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- <el-select :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="content.courseType"
- placeholder="请选择消息类型" size="mini"
- style=" margin-right: 10px;" v-if="content.type != 4 ">
- <el-option
- v-for="dict in sysFsSopWatchStatus"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="Number(dict.dictValue)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="Ai触达" v-if="content.type == 4 ">
- <el-select :disabled="formType == 3" v-model="content.aiTouch"
- placeholder="请选择Ai触达类型" size="mini"
- style=" margin-right: 10px;" v-if="content.type == 4 ">
- <el-option label="非首次交流" value="非首次交流"></el-option>
- <el-option label="首次交流1" value="首次交流1"></el-option>
- <el-option label="首次交流2" value="首次交流2"></el-option>
- <el-option label="交流状态1" value="交流状态1"></el-option>
- <el-option label="交流状态2" value="交流状态2"></el-option>
- <el-option label="交流状态3" value="交流状态3"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="添加标签" prop="addTag" v-if="content.type == 5 "
- v-model="content.addTag">
- <el-tag
- :key="tag"
- v-for="tag in content.addTag"
- closable
- :disable-transitions="false"
- @close="handleClose(contentIndex,tag,content)">
- {{ tag }}
- </el-tag>
- <el-input
- style="width:110px"
- class="input-new-tag"
- v-if="addTag[contentIndex] && addTag[contentIndex].inputVisible"
- v-model="addTag[contentIndex].inputValue"
- ref="saveTagInput"
- size="small"
- @keyup.enter.native="handleInputConfirm(contentIndex,content)"
- @blur="handleInputConfirm(contentIndex,content)"
- >
- </el-input>
- <el-button v-else class="button-new-tag" size="small" style="width: 110px"
- @click="showInput(contentIndex)">新增标签
- </el-button>
- </el-form-item>
- <el-form-item label="移除标签" prop="remarkMobiles" v-if="content.type == 5 ">
- <el-tag
- :key="tag"
- v-for="tag in content.delTag"
- closable
- :disable-transitions="false"
- @close="handleCloseDel(contentIndex,tag,content)">
- {{ tag }}
- </el-tag>
- <el-input
- style="width:110px"
- class="input-new-tag"
- v-if="addTag[contentIndex] && addTag[contentIndex].delTagVisible"
- v-model="addTag[contentIndex].delTagValue"
- ref="saveTagInputDel"
- size="small"
- @keyup.enter.native="handleInputConfirmDel(contentIndex,content)"
- @blur="handleInputConfirmDel(contentIndex,content)"
- >
- </el-input>
- <el-button v-else class="button-new-tag" size="small" style="width: 110px"
- @click="showInputDel(contentIndex)">新增标签
- </el-button>
- </el-form-item>
- <div v-for="(setList, setIndex) in content.setting" :key="setIndex"
- style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;"
- v-if="content.type != 4 && content.type != 5">
- <el-row style="padding-bottom: 20px">
- <el-col :span="22">
- <el-form :model="setList" label-width="70px">
- <el-form-item label="内容类别" style="margin: 2%">
- <div v-if="form.sendType == 1 ">
- <el-radio-group v-model="setList.contentType" :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')">
- <!-- <el-radio :label="item.dictValue" v-for="item in sysQwSopContentType">{{item.dictLabel}}</el-radio>-->
- <el-radio
- v-for="item in sysQwSopContentType"
- :key="item.dictValue"
- :label="item.dictValue"
- :disabled="item.dictValue === '1' && content.setting.some(s => s.contentType == '1') ">
- {{ item.dictLabel }}
- </el-radio>
- </el-radio-group>
- </div>
- <div v-if="form.sendType == 2">
- <el-radio-group v-model="setList.contentType"
- :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- @change="handleContentTypeChange(content,index,contentIndex,setIndex, item, 'contentType', $event)">
- <el-radio
- :key="item.dictValue"
- :label="item.dictValue"
- :disabled="(content.type!=2 && item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue))"
- v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
- </el-radio>
- </el-radio-group>
- </div>
- <div v-if=" form.sendType == 4">
- <el-radio-group v-model="setList.contentType"
- :disabled="formType == 3"
- @change="handleContentTypeChange(content,index,contentIndex,setIndex)">
- <el-radio
- :key="item.dictValue"
- :label="item.dictValue"
- :disabled="((content.type!=2 || form.sendType == 4) && (item.dictValue === '8' || item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue)))"
- v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
- </el-radio>
- </el-radio-group>
- </div>
- <div v-if="form.sendType == 11">
- <el-radio-group v-model="setList.contentType"
- :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
- @change="handleContentTypeChange(content,index,contentIndex,setIndex, item, 'contentType', $event)">
- <el-radio
- :key="item.dictValue"
- :label="item.dictValue"
- :disabled="(content.type!=2 && item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue))"
- v-for="item in sysQwSopAiContentType"
- v-if="courseTypeList.includes(item.dictValue)">{{ item.dictLabel }}
- </el-radio>
- </el-radio-group>
- </div>
- </el-form-item>
- <el-form-item label="内容">
- <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-if="setList.contentType == 1 || setList.contentType == 15"
- v-model="setList.value"
- type="textarea" :rows="3" placeholder="内容"
- style="width: 90%;margin-top: 10px;"
- @keydown.native="handleKeydown($event, index, contentIndex, setIndex)"
- :ref="`textarea-${index}-${contentIndex}-${setIndex}`"
- />
- <!-- 修改按钮部分 -->
- <el-link
- v-if="(setList.contentType == 1 || setList.contentType == 15) && roles.includes('edit_sop_temp_content')"
- type="primary"
- @click="toggleSalesCall(index, contentIndex, setIndex)"
- style="margin-top: 10px;"
- >
- {{ setList.isSalesCallAdded ? '移除#销售称呼#' : '添加#销售称呼#' }}
- </el-link>
- <el-link
- v-if="(setList.contentType == 1 || setList.contentType == 15) && roles.includes('edit_sop_temp_content')"
- type="primary"
- @click="toggleUserNameCall(index, contentIndex, setIndex)"
- style="margin-top: 10px; margin-left: 20px"
- >
- {{ setList.isUserNameCallAdded ? '移除#客户称呼#' : '添加#客户称呼#' }}
- </el-link>
- <ImageUpload :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-if="setList.contentType == 2 "
- v-model="setList.imgUrl"
- type="image" :num="1" :width="150" :height="150"/>
- <div
- v-if="(setList.contentType == 3 || item.contentType ==9) || (setList.contentType == 9 && content.type==2 )">
- <el-card class="box-card">
- <el-form-item label="链接标题:" label-width="100px" required>
- <el-input :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" v-model="setList.linkTitle"
- @change="updateAll(setIndex, item, 'linkTitle', $event)"
- placeholder="请输入链接标题"
- style="width: 90%;"/>
- </el-form-item>
- <el-form-item label="链接描述:" label-width="100px" required>
- <el-input :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" type="textarea" :rows="3"
- v-model="setList.linkDescribe"
- @change="updateAll(setIndex, item, 'linkDescribe', $event)"
- placeholder="请输入链接描述"
- style="width: 90%;margin-top: 1%;"/>
- </el-form-item>
- <el-form-item label="链接封面:" label-width="100px" required>
- <ImageUpload :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" v-model="setList.linkImageUrl"
- type="image" :num="1"
- @input="updateAll(setIndex, item, 'linkImageUrl', $event)"
- :file-size="2" :width="150" :height="150"
- style="margin-top: 1%;"/>
- </el-form-item>
- <div v-if="content.type != 2 " style="margin-top: 1%">
- <el-form-item label="链接地址:" label-width="100px" required>
- <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.linkUrl"
- placeholder="请输入链接地址"
- style="width: 90%;"/>
- </el-form-item>
- </div>
- <div v-if="content.type == 2 ">
- <el-form-item label="链接地址:" label-width="100px">
- <el-tag type="warning" v-model="setList.isBindUrl = 1 ">选择的课程小节
- 即为卡片链接地址
- </el-tag>
- </el-form-item>
- </div>
- </el-card>
- </div>
- <div v-if="setList.contentType == 4 || setList.contentType == 10">
- <el-card class="box-card">
- <el-form-item label="标题" prop="miniprogramTitle">
- <el-input v-model="setList.miniprogramTitle"
- :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
- @change="updateAll(setIndex, item, 'miniprogramTitle', $event)"
- placeholder="请输入小程序消息标题,最长为64字节" :rows="2"
- maxlength="64" type="textarea"
- @input="checkByteLength(content,setList.contentType,content.isOfficial)"/>
- </el-form-item>
- <el-form-item label="封面" prop="miniprogramPicUrl">
- <ImageUpload v-if="content.isOfficial !== '1'"
- @change="updateAll(setIndex, item, 'miniprogramPicUrl', $event)"
- :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
- v-model="setList.miniprogramPicUrl" type="image" :num="10"
- :width="150" :height="150"/>
- </el-form-item>
- <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
- <el-input v-model="setList.miniprogramAppid='wx73f85f8d62769119' " :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- disabled/>
- </el-form-item>
- <el-form-item label="page路径" prop="miniprogramPage" v-show="setList.contentType == 10"
- label-width="100px" style="margin-left: -30px">
- <el-input v-model="setList.miniprogramPage"
- :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- placeholder="小程序消息打开后的路径" type="textarea" :rows="3" />
- </el-form-item>
- </el-card>
- </div>
- <div v-if="setList.contentType == 12">
- <!-- <div >-->
- <el-card class="box-card">
- <el-form-item label="直播间" >
- <el-select v-model="setList.liveId"
- placeholder="请选择直播间" size="mini"
- :disabled="content.type==20"
- @change="liveChange(setList)" >
- <el-option
- v-for="dict in liveList"
- :key="dict.liveId"
- :label="dict.liveName"
- :value="dict.liveId"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="标题" prop="miniprogramTitle">
- <el-input :disabled="content.type==20" v-model="setList.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字节" :rows="2" maxlength="64"
- type="textarea" @input="checkByteLength(content,setList.contentType,content.isOfficial)" />
- </el-form-item>
- <el-form-item label="封面" prop="miniprogramPicUrl">
- <ImageUpload :disabled="content.type==20" v-model="setList.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
- </el-form-item>
- <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
- <el-input v-model="setList.miniprogramAppid='wx503cf8ab31f83dd4' " disabled />
- </el-form-item>
- <el-form-item label="page路径" prop="miniprogramPage" v-show="false" label-width="100px" style="margin-left: -30px">
- <el-input v-model="setList.miniprogramPage" placeholder="小程序消息打开后的路径" disabled />
- </el-form-item>
- </el-card>
- </div>
- <div v-if="setList.contentType == 5 ">
- <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
- <el-upload
- :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- v-model="setList.fileUrl"
- class="avatar-uploader"
- :action="uploadUrl"
- :show-file-list="false"
- :on-success="(res, file) => handleAvatarSuccessFile(res, file, setList)"
- :before-upload="beforeAvatarUploadFile">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <el-link v-if="setList.fileUrl" type="primary"
- :href="downloadUrl(setList.fileUrl)" download>
- {{ setList.fileUrl }}
- </el-link>
- </el-form-item>
- </div>
- <div v-if="setList.contentType == 6 ">
- <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
- <el-upload
- :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- v-model="setList.videoUrl"
- class="avatar-uploader"
- :action="uploadUrl"
- :show-file-list="false"
- :on-success="(res, file) => handleAvatarSuccessVideo(res, file, setList)"
- :before-upload="beforeAvatarUploadVideo">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <video v-if="setList.videoUrl"
- :src="setList.videoUrl"
- controls style="width: 200px;height: 100px">
- </video>
- </el-form-item>
- </div>
- <div v-if="setList.contentType == 7 || setList.contentType == 16">
- <el-input
- :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
- v-model="setList.value"
- type="textarea" :rows="3" maxlength="66" show-word-limit
- placeholder="输入要转为语音的内容"
- style="width: 90%;margin-top: 10px;"
- @input="handleInputVideoText(setList.value,setList)"/>
- </div>
- <div v-if="setList.contentType == 8 ">
- <el-button :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" type="primary"
- style="margin-bottom: 1%"
- @click="hanldeSelectVideoNum(content,index,contentIndex,setIndex)">
- 选择视频号
- </el-button>
- <el-card class="box-card" v-if="setList.coverUrl">
- <el-form-item label="封面标题:" label-width="100px">
- <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.nickname"
- style="width: 90%;margin-bottom: 1%" disabled/>
- </el-form-item>
- <el-form-item label="头像:" label-width="100px">
- <el-image
- v-if="setList.avatar != null"
- :src="setList.avatar"
- :preview-src-list="[setList.avatar]"
- :style="{ width: '50px', height: '50px' }"
- ></el-image>
- </el-form-item>
- <el-form-item label="封面:" label-width="100px">
- <el-image
- v-if="setList.coverUrl != null"
- :src="setList.coverUrl"
- :preview-src-list="[setList.coverUrl]"
- :style="{ width: '200px', height: '200px' }"
- ></el-image>
- </el-form-item>
- <el-form-item label="简介:" label-width="100px">
- <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" type="textarea" :rows="3"
- v-model="setList.desc"
- style="width: 90%;margin-top: 1%;" disabled/>
- </el-form-item>
- <el-form-item label="视频地址:" label-width="100px"
- style="margin-top: 1%">
- <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.url"
- style="width: 90%;" disabled/>
- </el-form-item>
- </el-card>
- </div>
- <div v-if="setList.contentType == 14">
- <el-card class="box-card">
- <el-form-item label="福袋名称" >
- <el-select :disabled="formType == 3" v-model="setList.luckyBagId"
- placeholder="请选择福袋" size="mini"
- @change="getLuckyBagStatus(setList)" >
- <el-option
- v-for="dict in luckyBagList"
- :key="dict.id"
- :label="dict.name"
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="福袋状态" >
- <el-tag :disabled="formType == 3" :type="setList.luckyBagDataStatus == 1 ? 'success' : 'danger'">
- {{ setList.luckyBagDataStatus == 1 ? '启用' : '禁用' }}
- </el-tag>
- </el-form-item>
- </el-card>
- </div>
- </el-form-item>
- <!-- <el-form-item label="添加短链"-->
- <!-- v-if="content.type == 2 && setList.contentType == 1 ">-->
- <!-- <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark"-->
- <!-- :disabled="!content.videoId">-->
- <!-- <el-switch-->
- <!-- @change="updateHtml"-->
- <!-- v-model="setList.isBindUrl"-->
- <!-- :disabled="!content.videoId && formType == 3 && !roles.includes('edit_sop_temp_content')"-->
- <!-- active-color="#13ce66"-->
- <!-- inactive-color="#DCDFE6"-->
- <!-- active-value="1"-->
- <!-- inactive-value="2">-->
- <!-- </el-switch>-->
- <!-- </el-tooltip>-->
- <!-- <span v-if="setList.isBindUrl == '1'"-->
- <!-- style="margin-left: 10px; color: #13ce66">添加URL</span>-->
- <!-- <span v-if="setList.isBindUrl == '2'"-->
- <!-- style="margin-left: 10px; color: #b1b4ba">不加URL</span>-->
- <!-- </el-form-item>-->
- <el-form-item label="课节过期时间"
- v-if="content.type == 2 && (setList.isBindUrl == '1' || setList.contentType==4) && setList.contentType != 2 && setList.contentType != 5 && setList.contentType != 6 && setList.contentType != 8 && setList.contentType != 9 && setList.contentType != 10 ">
- <el-row>
- <el-input type="number" v-model="setList.expiresDays"
- :disabled="!roles.includes('edit_sop_temp_content') && (formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0))"
- @change="updateAll(setIndex, item, 'expiresDays', $event)"
- style="width: 200px">
- <template slot="append">天</template>
- </el-input>
- </el-row>
- <el-row>
- <span class="tip">填写0或不填时,默认为系统配置的默认时间</span>
- </el-row>
- </el-form-item>
- </el-form>
- <el-form v-if="form.sendType == 4" :model="setList" label-width="70px">
- <el-form-item label="添加客服" prop="intervalTime" style="margin: 2%">
- <el-input-number
- v-model="setList.intervalTime"
- :min="1"
- :max="1440"
- style="width:150px;margin-top: 10px;"
- >
- </el-input-number>
- <span class="tip">单位:分钟,最大1440分钟(24小时)</span>
- </el-form-item>
- <!-- <el-form-item label="内容" style="margin: 2%">-->
- <!-- <el-input-->
- <!-- v-model="setList.value"-->
- <!-- type="textarea"-->
- <!-- :rows="3"-->
- <!-- placeholder="内容"-->
- <!-- style="width: 90%;margin-top: 10px;"/>-->
- <!-- </el-form-item>-->
- <!-- <el-form-item label="交流状态" style="margin: 2%">-->
- <!-- <el-select v-model="setList.talkType" placeholder="更改交流状态" size="mini"-->
- <!-- style=" margin-right: 10px;" clearable>-->
- <!-- <el-option label="非首次交流" value="非首次交流"></el-option>-->
- <!-- <el-option label="首次交流1" value="首次交流1"></el-option>-->
- <!-- <el-option label="首次交流2" value="首次交流2"></el-option>-->
- <!-- <el-option label="交流状态1" value="交流状态1"></el-option>-->
- <!-- <el-option label="交流状态2" value="交流状态2"></el-option>-->
- <!-- <el-option label="交流状态3" value="交流状态3"></el-option>-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
- </el-form>
- </el-col>
- <el-col :span="1" :offset="1">
- <i class="el-icon-delete" @click="delSetList(index,contentIndex,setIndex)"
- style="margin-top: 20px;"
- v-if="content.setting.length>1 && (formType != 3) && roles.includes('del_sop_temp_content') && !(form.sendType == 11 && setIndex == 0)"></i>
- </el-col>
- </el-row>
- </div>
- <el-link type="primary" class="el-icon-plus" :underline="false"
- @click='addSetList(contentIndex,item.content)'
- v-if="content.type != 4 && formType != 3 && roles.includes('add_sop_temp_content')">添加内容
- </el-link>
- </el-form>
- </el-col>
- <el-col :span="1" :offset="1">
- <i class="el-icon-delete" @click="delContent(index,contentIndex)"
- style="margin-top: 20px;"
- v-if="item.content.length>1 && formType != 3 && roles.includes('del_sop_temp_rule')"></i>
- </el-col>
- </el-row>
- </div>
- <el-link type="primary" class="el-icon-plus" :underline="false" @click='addContent(index)'
- v-if="formType != 3 && form.sendType != 4 && roles.includes('add_sop_temp_rule')">添加规则
- </el-link>
- </el-form-item>
- </el-form>
- </div>
- <div style="float: right;" v-if="formType != 3 && roles.includes('update_sop_temp_day')">
- <el-button type="primary" @click="save" v-if="!item.voice || item.voice == 0">
- 保存({{ '第' + (1 + (form.gap * index)) + '天' }})
- </el-button>
- <el-button type="primary" disabled v-if="item.voice == 1">语言生成中</el-button>
- <el-button type="primary" @click="leave(tabIndex)" v-if="item.voice == 1">刷新状态</el-button>
- </div>
- </el-col>
- </el-row>
- </el-tab-pane>
- </el-tabs>
- </el-form-item>
- </el-form>
- </div>
- <el-dialog :title="videoNumOptions.title" :visible.sync="videoNumOptions.open" style="width: 1500px;height: 100%"
- append-to-body>
- <userVideo ref="QwUserVideo" @videoResult="qwUserVideoResult"></userVideo>
- </el-dialog>
- <el-dialog title="修改天数排序" :visible.sync="openSort" style="width: 1500px" append-to-body>
- <draggable v-model="dayList" @end="onDragEndDay" style="padding: 20px">
- <el-button v-for="(item, index) in dayList" :class="item.newDay != item.dayNum ? 'red':''">第{{
- item.newDay
- }}天(第{{ item.dayNum }}天)
- </el-button>
- </draggable>
- <div style="float: right;">
- <el-button type="primary" @click="saveSorts">保存</el-button>
- </div>
- </el-dialog>
- <el-dialog title="修改规则排序" :visible.sync="openSort2" style="width: 1500px" append-to-body>
- <draggable v-model="ruleList" @end="onDragEnd" style="padding: 20px">
- <el-button v-for="(item, index) in ruleList">{{ item.time }}</el-button>
- </draggable>
- <div style="float: right;">
- <el-button @click="autoSortsRules">自动排序</el-button>
- <el-button type="primary" @click="saveSortsRules">保存</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <style scoped>
- .el-button {
- margin-left: 10px;
- }
- .red:hover {
- color: #dbdbdb !important;
- }
- .red {
- background-color: #F56C6C !important;
- color: #fff !important;
- }
- .custom-input /deep/ .el-input__inner {
- height: 20px;
- text-align: center;
- }
- .custom-input /deep/ .el-input__icon {
- line-height: 10px;
- }
- .el-icon-delete {
- cursor: pointer;
- }
- /deep/ .el-badge__content.is-fixed {
- top: 10px !important;
- right: 0 !important;
- width: 8px;
- }
- .tip {
- color: #909399;
- font-size: 12px;
- margin-left: 10px;
- }
- .sortable-ghost {
- background: rgb(26, 164, 255) !important;
- color: #FFF !important;
- }
- </style>
- <script>
- import draggable from 'vuedraggable';
- import {
- listSopTemp,
- getSopTemp,
- delSopTemp,
- addSopTemp,
- sortDay,
- dayListFun,
- updateSopTemp,
- exportSopTemp,
- addOrUpdateSetting,
- getSelectableRange,
- selectRulesInfo,
- delRules
- } from "@/api/qw/sopTemp";
- import {courseList, videoList} from "@/api/qw/sop";
- import {listToLiveNoEnd} from "@/api/live/live";
- import ImageUpload from "@/views/qw/sop/ImageUpload";
- import userVideo from "@/views/qw/userVideo/userVideo.vue";
- import {listReward} from "@/api/qw/luckyBag";
- import {
- getRoles,
- } from "@/api/qw/sop";
- export default {
- name: "updateSopTemp",
- components: {ImageUpload, userVideo, draggable},
- data() {
- return {
- queryParams1: {
- pageNum: 1,
- pageSize: 10,
- dataStatus: '1',
- name: null,
- type: null
- },
- luckyBagList: [],
- projectFrom:process.env.VUE_APP_PROJECT_FROM,
- addTag: [{
- addTag: [],
- inputVisible: false,
- inputValue: '',
- delTag: [],
- delTagVisible: false,
- delTagValue: ''
- }],
- uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS2",
- uploadUrlByVoice: process.env.VUE_APP_BASE_API + "/common/uploadOSSByHOOKVoice",
- //上传语音的遮罩层
- voiceLoading: false,
- openSort: false,
- openSort2: false,
- // 遮罩层
- loading: false,
- loading2: false,
- loading3: false,
- // 导出遮罩层
- exportLoading: false,
- roles: [],
- // 选中数组
- dayList: [],
- ruleList: [],
- ids: [],
- // startTimeRange: [],
- courseTypeList: ['1','2', '4','5','6', '7','8','9','10'],
- sysFsSopWatchStatus: [],
- //消息内容类型 企微版
- sysQwSopContentType: [],
- //插件版
- sysQwSopAiContentType: [],
- //类别
- sysQwSopSettingType: [],
- courseList: [],
- videoList: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- defaultContentType: 1,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- id: "",
- total: 0,
- tabIndex: null,
- // sop模板表格数据
- setting: [],
- data: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 状态字典
- statusOptions: [],
- videoNumOptions: {
- title: '选择视频号',
- open: false,
- content: null,
- contentIndex: null,
- setIndex: null,
- },
- //1 修改 2 复制 3 查看
- formType: null,
- // 查询参数
- form: {
- name: null,
- setting: null,
- status: "1",
- sort: 1,
- companyId: null,
- gap: 1,
- },
- // 缓存对象用于存储预加载的数据
- tabCache: {},
- // 标记哪些tab已经被请求过
- loadedTabs: new Set(),
- // 标记正在加载的tab,避免重复请求
- loadingTabs: new Set(),
- // 表单校验
- rules: {
- name: [
- {required: true, message: '名称不能为空', trigger: 'blur'}
- ],
- status: [
- {required: true, message: '状态不能为空', trigger: 'blur'}
- ],
- sort: [
- {required: true, message: '排序不能为空', trigger: 'blur'}
- ],
- gap: [
- {required: true, message: '间隔天数不能为空', trigger: 'blur'}
- ],
- },
- liveList: [],
- };
- },
- created() {
- getRoles().then(res => {
- this.roles = res.data;
- })
- this.getDicts("sys_qwSopAi_contentType").then(response => {
- this.sysQwSopAiContentType = response.data;
- });
- this.getDicts("sys_fs_sop_watch_status").then(response => {
- this.sysFsSopWatchStatus = response.data;
- });
- // getSelectableRange().then(e => {
- // this.startTimeRange = e.data;
- // })
- this.getDicts("sys_qwSop_contentType").then(response => {
- this.sysQwSopContentType = response.data;
- });
- this.getDicts("sys_company_status").then(response => {
- this.statusOptions = response.data;
- });
- this.getDicts("sys_qwSop_settingType").then(response => {
- this.sysQwSopSettingType = response.data;
- });
- courseList().then(response => {
- this.courseList = response.list;
- });
- listToLiveNoEnd().then(response => {
- this.liveList = response.rows;
- })
- listReward(this.queryParams1).then(response => {
- this.luckyBagList = response.rows;
- });
- const id = this.$route.params && this.$route.params.id;
- this.id = id;
- this.formType = this.$route.params && this.$route.params.type;
- console.info(this.form)
- this.handleUpdate(id);
- },
- methods: {
- getLuckyBagStatus(content) {
- const selectedLuckyBag = this.luckyBagList.find(item => item.id === content.luckyBagId);
- if (selectedLuckyBag) {
- content.luckyBagDataStatus = selectedLuckyBag.dataStatus; // 自动填充标题
- } else {
- // 若未找到对应直播间,清空标题和封面(可选)
- content.luckyBagDataStatus = null;
- }
- },
- liveChange(content) {
- // content.liveId 是选中的直播间 ID(liveId)
- const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
- if (selectedLive) {
- // 从选中的直播间对象中提取标题和封面,赋值给当前内容的对应字段
- // 假设直播间对象中标题字段为 liveTitle,封面字段为 coverImg(根据实际接口字段调整)
- content.miniprogramTitle = selectedLive.liveName || ''; // 自动填充标题
- content.miniprogramPicUrl = selectedLive.liveImgUrl || ''; // 自动填充封面
- } else {
- // 若未找到对应直播间,清空标题和封面(可选)
- content.miniprogramTitle = '';
- content.miniprogramPicUrl = '';
- }
- },
- liveChangeContent(e){
- //循环修改当前content下面的直播间内容
- //并且禁用直播间编辑
- if(!!e && !!e.setting){
- for(let i=0;i<e.setting.length;i++){
- if(!!e.liveId){
- this.$set(e.setting[i], 'liveId', e.liveId);
- this.liveChange(e.setting[i]);
- }
- //直播间变为不可编辑
- this.$set(e.setting[i], 'setListDisabled', true);
- }
- }
- },
- handleClose(index, tag, content) {
- content.addTag.splice(content.addTag.indexOf(tag), 1);
- },
- showInput(index) {
- this.addTag[index].inputVisible = true;
- },
- handleInputConfirm(index, content) {
- let inputValue = this.addTag[index].inputValue;
- if (inputValue) {
- if (!content.hasOwnProperty('addTag')) {
- this.$set(content, 'addTag', []);
- }
- content.addTag.push(inputValue);
- }
- this.addTag[index].inputVisible = false;
- this.addTag[index].inputValue = '';
- },
- // 检查字节长度
- checkByteLength(content, type, isOfficial) {
- if (type == 4 && isOfficial == '1')
- for (let i = 0; i < content.setting.length; i++) {
- const text = content.setting[i].miniprogramTitle;
- const byteLength = this.getByteLength(text); // 获取当前字节数
- // 如果字节数超过64,截断输入内容
- if (byteLength > 64) {
- this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(text, 60));
- }
- }
- },
- // 计算字符串的字节数
- getByteLength(text) {
- return new Blob([text]).size; // 使用 Blob 计算字节数
- },
- // 根据字节数截断字符串
- truncateTextByByteLength(text, maxByteLength) {
- let byteLength = 0;
- let result = "";
- for (let i = 0; i < text.length; i++) {
- const char = text[i];
- const charByteLength = this.getByteLength(char); // 获取当前字符的字节数
- // 如果加上当前字符的字节数后不超过限制,则添加到结果中
- if (byteLength + charByteLength <= maxByteLength) {
- result += char;
- byteLength += charByteLength;
- } else {
- break; // 超过限制时停止
- }
- }
- return result;
- },
- handleCloseDel(index, tag, content) {
- content.delTag.splice(content.delTag.indexOf(tag), 1);
- },
- showInputDel(index) {
- this.addTag[index].delTagVisible = true;
- },
- handleInputConfirmDel(index, content) {
- let delTagValue = this.addTag[index].delTagValue;
- if (delTagValue) {
- if (!content.hasOwnProperty('delTag')) {
- this.$set(content, 'delTag', []);
- }
- content.delTag.push(delTagValue);
- }
- this.addTag[index].delTagVisible = false;
- this.addTag[index].delTagValue = '';
- },
- saveSorts() {
- let list = this.dayList.filter(e => e.dayNum != e.newDay).map(e => {
- return {dayNum: e.newDay, id: e.id}
- })
- this.loading3 = true;
- sortDay(list).then(e => {
- window.location.reload();
- })
- },
- saveSortsRules() {
- this.$set(this.setting[this.tabIndex], 'content', this.ruleList);
- this.openSort2 = false;
- },
- autoSortsRules() {
- this.ruleList = this.ruleList.sort((a, b) => {
- // 将 time 字段转换为 Date 对象进行比较
- const timeA = new Date(`1970-01-01T${a.time}Z`);
- const timeB = new Date(`1970-01-01T${b.time}Z`);
- // 比较时间顺序
- return timeA - timeB; // 升序排序
- });
- },
- openUpdateDaySorts() {
- dayListFun(this.id).then(response => {
- response.data.forEach((item) => item.newDay = item.dayNum);
- this.dayList = response.data;
- if (this.dayList == null || this.dayList.length == 0) {
- this.$message.error("暂无天数")
- } else {
- this.openSort = true;
- }
- })
- },
- openUpdateSorts() {
- this.ruleList = JSON.parse(JSON.stringify(this.setting[this.tabIndex].content));
- if (this.ruleList == null || this.ruleList.length == 0) {
- this.$message.error("暂无规则")
- } else {
- this.openSort2 = true;
- }
- },
- onDragEndDay() {
- this.dayList.forEach((item, index) => {
- item.newDay = (this.form.gap * index) + 1;
- })
- this.$forceUpdate()
- },
- onDragEnd() {
- // 更新排序值
- // this.setting[this.tabIndex].content.forEach((item, index) => {
- // item.sorts = index;
- // });
- },
- // 切换标签保存数据
- async leave(index, oldIndex) {
- const newData = this.setting[index]
- if (newData.dayNum && newData.id) {
- // 检查是否已经有缓存数据
- if (this.tabCache[newData.id]) {
- // 使用缓存数据,无需loading
- this.applyCachedData(index, newData);
- } else {
- // 没有缓存,需要请求数据
- this.loading = true;
- try {
- const res = await selectRulesInfo(newData.id);
- // 缓存数据
- this.tabCache[newData.id] = res.data;
- this.loadedTabs.add(index);
- this.applyDataToTab(index, newData, res.data);
- } catch (error) {
- console.error("获取规则信息失败:", error);
- } finally {
- this.loading = false;
- }
- }
- // 预加载下一个tab的数据
- this.preloadNextTab(index);
- }
- },
- // 应用缓存数据到tab
- applyCachedData(index, newData) {
- const cachedData = this.tabCache[newData.id];
- this.$nextTick(() => {
- this.videoList = [];
- this.addTag = [];
- this.$set(this.setting, index, {
- ...newData,
- voice: cachedData.voice,
- content: cachedData.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
- });
- for (let j = 0; j < this.setting[index].content.length; j++) {
- if (this.setting[index].content[j].addTag != null) {
- this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
- }
- if (this.setting[index].content[j].delTag != null) {
- this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
- }
- this.videoList.push([])
- this.addTag.push({
- addTag: [],
- inputVisible: false,
- inputValue: '',
- delTag: [],
- delTagVisible: false,
- delTagValue: ''
- })
- if (this.setting[index].content[j].type == 2) {
- if (this.setting[index].content[j].hasOwnProperty('courseId')) {
- this.courseChange(this.setting[index].content[j], index, j);
- }
- }
- }
- });
- },
- // 应用新获取的数据到tab
- applyDataToTab(index, newData, data) {
- this.$nextTick(() => {
- this.videoList = [];
- this.addTag = [];
- this.$set(this.setting, index, {
- ...newData,
- voice: data.voice,
- content: data.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
- });
- for (let j = 0; j < this.setting[index].content.length; j++) {
- if (this.setting[index].content[j].addTag != null) {
- this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
- }
- if (this.setting[index].content[j].delTag != null) {
- this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
- }
- this.videoList.push([])
- this.addTag.push({
- addTag: [],
- inputVisible: false,
- inputValue: '',
- delTag: [],
- delTagVisible: false,
- delTagValue: ''
- })
- if (this.setting[index].content[j].type == 2) {
- if (this.setting[index].content[j].hasOwnProperty('courseId')) {
- this.courseChange(this.setting[index].content[j], index, j);
- }
- }
- }
- });
- },
- // 预加载下一个tab的数据
- async preloadNextTab(currentIndex) {
- const nextIndex = parseInt(currentIndex) + 1;
- // 检查是否有下一个tab
- if (nextIndex >= this.setting.length) {
- return;
- }
- const nextTabData = this.setting[nextIndex];
- // 只预加载已存在的tab(有id的),跳过新建的tab
- if (!nextTabData.id || !nextTabData.dayNum) {
- return;
- }
- // 如果已经加载过或正在加载,则跳过
- if (this.loadedTabs.has(nextIndex) || this.loadingTabs.has(nextIndex) || this.tabCache[nextTabData.id]) {
- return;
- }
- // 标记为正在加载
- this.loadingTabs.add(nextIndex);
- try {
- const res = await selectRulesInfo(nextTabData.id);
- // 缓存数据
- this.tabCache[nextTabData.id] = res.data;
- this.loadedTabs.add(nextIndex);
- } catch (error) {
- console.error("预加载tab数据失败:", error);
- } finally {
- // 移除加载标记
- this.loadingTabs.delete(nextIndex);
- }
- },
- save() {
- let data = this.setting[this.tabIndex];
- let check = this.checkData(data);
- if (!check) {
- return;
- }
- for (let j = 0; j < data.content.length; j++) {
- //如果不是每天第一条,全刷为非官方
- if (j!==0){
- data.content[j].isOfficial=0;
- }
- if (data.content[j].type != 4 && data.content[j].type != 5) {
- for (let k = 0; k < data.content[j].setting.length; k++) {
- if (data.content[j].setting[k].contentType == 4 && (data.content[j].setting[k].miniprogramTitle != null || data.content[j].setting[k].miniprogramTitle != "")) {
- data.content[j].setting[k].miniprogramTitle = this.truncateTextByByteLength(data.content[j].setting[k].miniprogramTitle, 60)
- }
- }
- }
- }
- let index = 0;
- const dataList = data.content.map(e => {
- e.name = data.name;
- e.tempId = this.id;
- e.sorts = Number(this.tabIndex);
- e.dayNum = (this.form.gap * e.sorts) + 1;
- e.sorts = index++;
- data.dayNum = e.dayNum;
- e.contentType = e.type;
- e.settingList = e.setting;
- e.settingList.forEach(e => e.content = JSON.stringify(e));
- if (e.addTag != null) {
- e.addTag = JSON.stringify(e.addTag);
- }
- if (e.delTag != null) {
- e.delTag = JSON.stringify(e.delTag);
- }
- return e;
- })
- data.tempId = this.id;
- data.list = dataList;
- this.loading = true;
- addOrUpdateSetting(data).then(e => {
- this.$message.success(e.msg)
- let content = this.setting[this.tabIndex].content;
- for (let j = 0; j < content.length; j++) {
- if (content[j].addTag != null) {
- content[j].addTag = JSON.parse(content[j].addTag);
- }
- if (content[j].delTag != null) {
- content[j].delTag = JSON.parse(content[j].delTag);
- }
- }
- this.loading = false;
- // 使用Vue.set确保响应式更新
- this.$set(this.setting, this.tabIndex, {
- ...this.setting[this.tabIndex],
- id: e.data.id,
- });
- // 更新缓存中的数据
- const currentTabId = this.setting[this.tabIndex].id;
- if (currentTabId) {
- // 重新获取最新数据并更新缓存
- selectRulesInfo(currentTabId).then(res => {
- this.tabCache[currentTabId] = res.data;
- this.loadedTabs.add(parseInt(this.tabIndex));
- }).catch(error => {
- console.error("更新缓存失败:", error);
- });
- }
- }).catch(() => {
- this.loading = false;
- });
- },
- checkData(data) {
- if (this.form.sendType != 4) {
- for (let j = 0; j < data.content.length; j++) {
- if (data.name == null || data.name == "") {
- this.$message.error("内容名称不能为空")
- return false;
- }
- if (data.content[j].time == null || data.content[j].time == "") {
- this.$message.error("时间不能为空")
- return false;
- }
-
- if (data.content[j].type == 20){
- if (data.content[j].liveId == null || data.content[j].liveId == "") {
- this.$message.error("请选择直播间")
- return false;
- }
- }
- if (data.content[j].type == 2) {
- if (data.content[j].courseId == null || data.content[j].courseId == "") {
- this.$message.error("请选择课程")
- return false;
- }
- if (data.content[j].videoId == null || data.content[j].videoId == "") {
- this.$message.error("请选择课节")
- return false;
- }
- if (data.content[j].courseType == null || data.content[j].courseType === "") {
- this.$message.error("请选择消息类型")
- return false;
- }
- }
- if (data.content[j].type != 4 && data.content[j].type != 5) {
- for (let k = 0; k < data.content[j].setting.length; k++) {
- if (data.content[j].setting[k].contentType == 1 && (data.content[j].setting[k].value == null || data.content[j].setting[k].value == "")) {
- this.$message.error("内容不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 2 && (data.content[j].setting[k].imgUrl == null || data.content[j].setting[k].imgUrl == "")) {
- this.$message.error("图片不能为空")
- return false;
- }
- if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkTitle == null || data.content[j].setting[k].linkTitle == "")) {
- this.$message.error("链接标题不能为空")
- return false;
- }
- if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkDescribe == null || data.content[j].setting[k].linkDescribe == "")) {
- this.$message.error("链接描述不能为空")
- return false;
- }
- if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkImageUrl == null || data.content[j].setting[k].linkImageUrl == "")) {
- this.$message.error("链接图片不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 3 && data.content[j].setting[k].type == 1 && (data.content[j].setting[k].linkUrl == null || data.content[j].setting[k].linkUrl == "")) {
- this.$message.error("链接地址不能为空")
- return false;
- }
- if ((data.content[j].setting[k].contentType == 4 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].miniprogramTitle == null || data.content[j].setting[k].miniprogramTitle == "")) {
- this.$message.error("小程序消息标题不能为空")
- return false;
- }
- if ((data.content[j].setting[k].contentType == 4 || data.content[j].setting[k].contentType == 10) && data.content[j].isOfficial !== '1' && (data.content[j].setting[k].miniprogramPicUrl == null || data.content[j].setting[k].miniprogramPicUrl == "")) {
- this.$message.error("小程序封面地址不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 10 && data.content[j].isOfficial !== '1' && (data.content[j].setting[k].miniprogramPage == null || data.content[j].setting[k].miniprogramPage == "")) {
- this.$message.error("小程序page地址不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 5 && (data.content[j].setting[k].fileUrl == null || data.content[j].setting[k].fileUrl == "")) {
- this.$message.error("文件不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 6 && (data.content[j].setting[k].videoUrl == null || data.content[j].setting[k].videoUrl == "")) {
- this.$message.error("视频不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 7 && (data.content[j].setting[k].value == null || data.content[j].setting[k].value == "")) {
- this.$message.error("语音文本不能为空")
- return false;
- }
- if (data.content[j].setting[k].contentType == 8 && (data.content[j].setting[k].url == null || data.content[j].setting[k].url == "")) {
- this.$message.error("视频号信息不能为空")
- return false;
- }
- }
- } else if (data.content[j].type == 4) {
- if (data.content[j].aiTouch == null || data.content[j].aiTouch == '') {
- this.$message.error("AI触达不能为空")
- return false;
- }
- }
- }
- } else {
- for (let day of this.setting) {
- for (let content of day.content) {
- for (let set of content.setting) {
- if (!set.intervalTime) {
- this.$message.error("客服时间不能为空");
- return false;
- }
- if (set.contentType == 1 && (set.value == null || set.value == "")) {
- this.$message.error("内容不能为空")
- return false;
- }
- if (set.contentType == 2 && (set.imgUrl == null || set.imgUrl == "")) {
- this.$message.error("图片不能为空")
- return false;
- }
- if ((set.contentType == 3 || set.contentType == 9) && (set.linkTitle == null || set.linkTitle == "")) {
- this.$message.error("链接标题不能为空")
- return false;
- }
- if ((set.contentType == 3 || set.contentType == 9) && (set.linkDescribe == null || set.linkDescribe == "")) {
- this.$message.error("链接描述不能为空")
- return false;
- }
- if ((set.contentType == 3 || set.contentType == 9) && (set.linkImageUrl == null || set.linkImageUrl == "")) {
- this.$message.error("链接图片不能为空")
- return false;
- }
- if (set.contentType == 3 && set.type == 1 && (set.linkUrl == null || set.linkUrl == "")) {
- this.$message.error("链接地址不能为空")
- return false;
- }
- if (set.contentType == 4 && (set.miniprogramTitle == null || set.miniprogramTitle == "")) {
- this.$message.error("小程序消息标题不能为空")
- return false;
- }
- if (set.contentType == 4 && (set.miniprogramPicUrl == null || set.miniprogramPicUrl == "")) {
- this.$message.error("小程序封面地址不能为空")
- return false;
- }
- if (set.contentType == 5 && (set.fileUrl == null || set.fileUrl == "")) {
- this.$message.error("文件不能为空")
- return false;
- }
- if (set.contentType == 6 && (set.videoUrl == null || set.videoUrl == "")) {
- this.$message.error("视频不能为空")
- return false;
- }
- if (set.contentType == 7 && (set.value == null || set.value == "")) {
- this.$message.error("语音文本不能为空")
- return false;
- }
- if (set.contentType == 8 && (set.url == null || set.url == "")) {
- this.$message.error("视频号信息不能为空")
- return false;
- }
- }
- }
- }
- }
- return true;
- },
- tabClick(obj) {
- },
- addSetList(contentIndex, content) {
- if (this.form.sendType == 1) {
- for (let i = 0; i < content.length; i++) {
- if (!content[i].setting) {
- content[i].setting = []; // 初始化 setting 数组如果不存在
- }
- if (content[i].setting.length > 9) {
- return this.$message.error("因为企微接口限制,企微模板一条消息只能设置最多~9个内容!!")
- } else {
- // 动态生成新的设置项
- const newSetting = content[i].setting.some(item => item.contentType === '1')
- ? {contentType: '2', imgUrl: ''} // 如果存在 contentType = '1',添加 contentType = '2'
- : {contentType: '1', value: ''}; // 如果不存在 contentType = '1',添加 contentType = '1'
- // 将新设置项添加到 content[i].setting 数组中
- content[i].setting.push(newSetting);
- }
- }
- } else {
- if (!content[contentIndex].setting) {
- content[contentIndex].setting = []; // 初始化 setting 数组如果不存在
- }
- const newSetting = {
- contentType: '1',
- value: '',
- };
- if (this.form.sendType === 4) {
- for (let i = 0; i < content.length; i++) {
- if (content[i].setting.length < 5) {
- // 将新设置项添加到 content.setting 数组中
- content[contentIndex].setting.push(newSetting);
- } else {
- return this.$message.error("因为要求限制,新课对话模板一条消息只能设置最多~5个内容!!")
- }
- }
- } else {
- // 将新设置项添加到 content.setting 数组中
- content[contentIndex].setting.push(newSetting);
- }
- }
- },
- delSetList(index, contentIndex, setIndex) {
- this.setting[index].content[contentIndex].setting.splice(setIndex, 1)
- },
- addContent(index) {
- if (this.setting[index].content.length > 0 && this.form.sendType == 1) {
- return this.$message.error("因为企微接口限制,企微模板一天只能设置一条消息~")
- } else {
- const sourceContent = this.setting[index].content[0];
- const newContent = {
- type: this.defaultContentType,
- contentType: 1,
- setting: [{contentType: '1', value: ""}],
- // 复制课程相关字段,如 courseId、videoId,根据实际数据结构补充
- courseId: sourceContent.courseId,
- videoId: sourceContent.videoId,
- courseType: sourceContent.courseType,
- isAtAll: '0',
- };
- this.setting[index].content.push(newContent);
- this.videoList.push([]);
- this.addTag.push({
- addTag: [],
- inputVisible: false,
- inputValue: '',
- delTag: [],
- delTagVisible: false,
- delTagValue: ''
- });
- // 如果有视频列表关联,也可同步处理 videoList,根据 courseId 重新请求或复制已有视频数据
- if (sourceContent.courseId) {
- this.courseUpdate(newContent, index, this.setting[index].content.length - 1);
- }
- }
- },
- delContent(index, contentIndex) {
- this.setting[index].content.splice(contentIndex, 1)
- this.videoList.splice(contentIndex, 1)
- this.addTag.splice(contentIndex, 1)
- },
- addSetting() {
- let content = [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: "",}],isAtAll: '0'}];
- if (this.form.sendType == 4) {
- content = [{type: 2, contentType: '1', setting: [{contentType: '1', value: "",}]}];
- content[0].setting[0].intervalTime = 5;
- }
- this.setting.push({
- name: null,
- dayNum: (this.form.gap * this.setting.length) + 1,
- content
- })
- },
- delSetting(index) {
- const newData = this.setting[index]
- if (newData.id && newData.dayNum) {
- this.$confirm('此操作将永久删除, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delRules(newData.id, newData.name, newData.dayNum).then(res => {
- this.del(index);
- });
- });
- } else {
- this.del(index);
- }
- },
- del(index) {
- if (index == 0) {
- this.tabIndex = "0";
- } else {
- this.tabIndex = (index - 1) + "";
- }
- this.setting.splice(index, 1)
- },
- handleClosegroupUser(list) {
- const index = this.userSelectList.findIndex(t => t === list);
- if (index !== -1) {
- this.userSelectList.splice(index, 1);
- }
- },
- //选择视频号
- hanldeSelectVideoNum(content, index, contentIndex, setIndex) {
- this.videoNumOptions.content = content;
- this.videoNumOptions.contentIndex = contentIndex;
- this.videoNumOptions.setIndex = setIndex;
- this.videoNumOptions.open = true;
- },
- qwUserVideoResult(val) {
- // 根据选中的内容,将返回的数据更新到相应的表单项
- const content = this.videoNumOptions.content;
- const setList = content.setting[this.videoNumOptions.setIndex];
- setList.nickname = val.nickname;
- setList.avatar = val.avatar;
- setList.coverUrl = val.coverUrl;
- setList.thumbUrl = val.thumbUrl;
- setList.desc = val.desc;
- setList.url = val.url;
- setList.extras = val.extras;
- setList.videoId = val.id;
- this.videoNumOptions.open = false;
- },
- //首次刷新
- courseChange(content, index, countIndex) {
- this.courseUpdate(content, index, countIndex);
- },
- //修改
- courseChangeUpdate(content, index, countIndex) {
- this.$set(content, 'videoId', null);
- // 查找选中的课程对应的 label
- const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
- for (let i = 0; i < content.setting.length; i++) {
- this.$set(content.setting[i], 'linkTitle', null);
- this.$set(content.setting[i], 'linkDescribe', null);
- this.$set(content.setting[i], 'linkImageUrl', null);
- //如果是链接的才上
- if (selectedCourse && content.type == 2 && content.courseId != null) {
- //响应式直接给链接的标题/封面上值
- if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
- this.$set(content.setting[i], 'linkTitle', selectedCourse.dictLabel);
- this.$set(content.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
- }
- if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10) {
- this.$set(content.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
- }
- }
- }
- this.courseUpdate(content, index, countIndex);
- },
- handleInputVideoText(value, content) {
- // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
- const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
- // 删除不符合条件的字符
- const filteredValue = value.split('').filter(char => regex.test(char)).join('');
- this.$set(content, 'value', filteredValue);
- },
- courseUpdate(content, index, countIndex) {
- videoList(content.courseId).then(response => {
- // this.$set(this.videoList, countIndex, response.list); // 响应式设置videoList
- this.videoList.splice(countIndex, 1, response.list);
- });
- },
- toggleSalesCall(itemIndex, contentIndex, setIndex) {
- // 获取目标对象
- const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
- const salesCall = '#销售称呼#';
- const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
- const textarea = this.$refs[refKey][0]?.$refs?.textarea;
- if (!textarea) return;
- // 获取光标位置
- const cursorPosition = textarea.selectionStart;
- if (setItem.isSalesCallAdded) {
- // 移除所有标签
- setItem.value = setItem.value.replace(new RegExp(salesCall, 'g'), '');
- } else {
- // 插入到光标位置
- setItem.value =
- setItem.value.slice(0, cursorPosition) +
- salesCall +
- setItem.value.slice(cursorPosition);
- }
- // 切换状态
- setItem.isSalesCallAdded = !setItem.isSalesCallAdded;
- // 保持光标位置
- this.$nextTick(() => {
- const newCursorPos = cursorPosition + (setItem.isSalesCallAdded ? salesCall.length : 0);
- textarea.setSelectionRange(newCursorPos, newCursorPos);
- });
- },
- toggleUserNameCall(itemIndex, contentIndex, setIndex) {
- // 获取目标对象
- const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
- const salesCall = '#客户称呼#';
- const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
- const textarea = this.$refs[refKey][0]?.$refs?.textarea;
- if (!textarea) return;
- // 获取光标位置
- const cursorPosition = textarea.selectionStart;
- if (setItem.isUserNameCallAdded) {
- // 移除所有标签
- setItem.value = setItem.value.replace(new RegExp(salesCall, 'g'), '');
- } else {
- // 插入到光标位置
- setItem.value =
- setItem.value.slice(0, cursorPosition) +
- salesCall +
- setItem.value.slice(cursorPosition);
- }
- // 切换状态
- setItem.isUserNameCallAdded = !setItem.isUserNameCallAdded;
- // 保持光标位置
- this.$nextTick(() => {
- const newCursorPos = cursorPosition + (setItem.isUserNameCallAdded ? salesCall.length : 0);
- textarea.setSelectionRange(newCursorPos, newCursorPos);
- });
- },
- handleKeydown(event, itemIndex, contentIndex, setIndex) {
- const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
- const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
- const textarea = this.$refs[refKey][0]?.$refs?.textarea;
- if (!textarea) return;
- const tags = ['#销售称呼#', '#客户称呼#'];
- const key = event.key;
- const value = setItem.value;
- const cursorPosition = textarea.selectionStart;
- if (key === 'Backspace' || key === 'Delete') {
- tags.forEach(tag => {
- let start, end;
- // Backspace 处理
- if (key === 'Backspace' && cursorPosition >= tag.length) {
- start = cursorPosition - tag.length;
- if (value.slice(start, cursorPosition) === tag) {
- event.preventDefault();
- setItem.value = value.slice(0, start) + value.slice(cursorPosition);
- if (tag === '#销售称呼#') setItem.isSalesCallAdded = false;
- this.$nextTick(() => textarea.setSelectionRange(start, start));
- }
- }
- // Delete 处理
- if (key === 'Delete') {
- end = cursorPosition + tag.length;
- if (value.slice(cursorPosition, end) === tag) {
- event.preventDefault();
- setItem.value = value.slice(0, cursorPosition) + value.slice(end);
- if (tag === '#销售称呼#') setItem.isSalesCallAdded = false;
- }
- }
- });
- }
- },
- handleContentTypeChange(content, index, countIndex, setIndex, item, fieldName, val) {
-
- //消息类别是直播间&&选择了发送直播间
-
- if(content.type == 20 && val == 12){
- //如果选择了直播间 直接赋值
- if(!!content.liveId){
- this.$set(content.setting[setIndex], 'liveId', content.liveId);
- this.liveChange(content.setting[setIndex]);
- }
- //直播间变为不可编辑
- this.$set(content.setting[setIndex], 'setListDisabled', true);
- }else{
- //取消禁用
- for (let i = 0; i < content.setting.length; i++) {
- this.$set(content.setting[i], 'setListDisabled', true);
- }
- }
- //如果是链接的才上
- if (content.courseId != null && content.type == 2) {
- const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
- for (let i = 0; i < content.setting.length; i++) {
- //响应式直接给链接的标题/封面上值
- if (selectedCourse && content.type == 2 && content.courseId != null) {
- if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
- this.$set(content.setting[i], 'linkTitle', selectedCourse.dictLabel);
- this.$set(content.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
- }
- if ((content.setting[i].contentType == 4 || content.setting[i].contentType == 10) && (content.isOfficial == '0' || content.isOfficial == null)) {
- this.$set(content.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
- }
- }
- }
- }
- if (content.videoId != null && content.type == 2) {
- // 查找选中的课节对应的 label
- const selectedVideo = this.videoList[countIndex].find(course => parseInt(course.dictValue) === content.videoId);
- for (let i = 0; i < content.setting.length; i++) {
- //响应式直接给链接的描述上值
- if (selectedVideo && content.type == 2 && content.videoId != null) {
- if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
- this.$set(content.setting[i], 'linkDescribe', selectedVideo.dictLabel);
- if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
- this.$set(content.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
- }
- }
- if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10 ) {
- this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel, 60));
- if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
- this.$set(content.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
- }
- }
- }
- }
- }
- if(countIndex == 0 && setIndex == 0){
- this.updateAll(setIndex, item, fieldName, val);
- for (let index in item.content) {
- if(index != 0){
- this.handleContentTypeChange(item.content[index], 0, index, 0, item, fieldName, val);
- }
- }
- }
- },
- videoIdChange(content, index, countIndex) {
- //选择了课程小节则 默认绑上
- let selectedVideo;
- // 查找选中的课程对应的 label
- if (content.videoId != null) {
- selectedVideo = this.videoList[countIndex].find(course => parseInt(course.dictValue) === content.videoId);
- }
- for (let i = 0; i < content.setting.length; i++) {
- //课程消息-文本内容
- if (content.setting[i].contentType == 1 && content.type == 2) {
- this.$set(content.setting[i], 'isBindUrl', '2');
- }
- //如果是链接的才上
- if (selectedVideo && content.type == 2 && content.videoId != null) {
- if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
- this.$set(content.setting[i], 'linkDescribe', selectedVideo.dictLabel);
- if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
- this.$set(content.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
- }
- }
- if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10) {
- this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel, 60));
- if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
- this.$set(content.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
- }
- }
- }
- }
- },
- //上传文件
- handleAvatarSuccessFile(res, file, content) {
- if (res.code === 200) {
- // 使用 $set 确保响应式更新
- this.$set(content, 'fileUrl', res.url);
- } else {
- this.msgError(res.msg);
- }
- },
- beforeAvatarUploadFile(file) {
- const isLt1M = file.size / 1024 / 1024 < 10;
- if (!isLt1M) {
- this.$message.error('上传大小不能超过 10MB!');
- }
- return isLt1M;
- },
- //下载文件
- downloadUrl(materialUrl) {
- // 直接返回文件 URL
- return materialUrl;
- },
- handleAvatarSuccessVideo(res, file, content) {
- if (res.code == 200) {
- // 使用 $set 确保响应式更新
- this.$set(content, 'videoUrl', res.url);
- } else {
- this.msgError(res.msg);
- }
- },
- beforeAvatarUploadVideo(file) {
- const isLt30M = file.size / 1024 / 1024 < 10;
- const isMP4 = file.type === 'video/mp4';
- if (!isMP4) {
- this.$message.error('仅支持上传 MP4 格式的视频文件!');
- return false;
- }
- if (!isLt30M) {
- this.$message.error('上传大小不能超过 10MB!');
- return false;
- }
- return true;
- },
- handleAvatarSuccessVoice(res, file, content) {
- if (res.code == 200) {
- // 创建 Audio 对象加载音频
- const audio = new Audio(res.mp3Url);
- audio.addEventListener('loadedmetadata', () => {
- // 获取音频时长
- this.$set(content, 'voiceDuration', Math.ceil(audio.duration));
- });
- // 使用 $set 确保响应式更新
- this.$set(content, 'voiceUrl', res.silkUrl);
- this.$set(content, 'mp3Url', res.mp3Url);
- } else {
- this.msgError(res.msg);
- }
- this.voiceLoading = false;
- },
- beforeAvatarUploadVoice(file) {
- return new Promise((resolve, reject) => {
- const isLt10M = file.size / 1024 / 1024 < 10; // 假设语音文件大小限制为10MB
- const isVoiceType = ['audio/mp3', 'audio/mpeg', 'audio/wav', 'audio/x-wav'].includes(file.type);
- if (!isVoiceType) {
- this.$message.error('仅支持上传 MP3, WAV, X-WAV 格式的语音文件!');
- return reject(false); // 不允许继续上传
- }
- if (!isLt10M) {
- this.$message.error('上传大小不能超过 10MB!');
- return reject(false); // 不允许继续上传
- }
- // 使用 FileReader 读取文件
- const reader = new FileReader();
- reader.onload = (event) => {
- const audio = new Audio(event.target.result);
- audio.addEventListener('loadedmetadata', () => {
- // 获取时长并保存
- if (Math.ceil(audio.duration) > 30) {
- this.$message.error('音频时长不能超过30秒!');
- this.voiceLoading = false;
- return reject(false); // 不允许继续上传
- }
- resolve(true); // 允许上传
- });
- };
- reader.onerror = () => {
- this.$message.error('无法读取音频文件!请上传正确的音频文件');
- reject(false); // 不允许继续上传
- };
- this.voiceLoading = true;
- reader.readAsDataURL(file); // 开始读取文件
- });
- },
- /** 查询sop模板列表 */
- getList() {
- this.loading = true;
- listSopTemp(this.queryParams).then(response => {
- this.sopTempList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.$store.dispatch("tagsView/delView", this.$route);
- this.$router.replace('/qw/conversion/sopTemp')
- // this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- name: null,
- setting: null,
- status: "0",
- sort: null,
- createTime: null,
- createBy: null,
- companyId: null
- };
- this.resetForm("form");
- },
- /** 修改按钮操作 */
- handleUpdate(id) {
- getSopTemp(id).then(response => {
- this.videoList = []
- this.form = response.data;
- this.setting = this.form.list || [];
- if (Array.isArray(this.setting)) {
- this.setting.forEach(item => {
- if (item && Array.isArray(item.content)) {
- item.content.forEach(content => {
- if (content.isAtAll === undefined || content.isAtAll === null) {
- this.$set(content, 'isAtAll', '0') // 默认关闭
- }
- // 如果后端返回的是数字,转换为字符串
- if (typeof content.isAtAll === 'number') {
- this.$set(content, 'isAtAll', content.isAtAll.toString())
- }
- if (content && Array.isArray(content.setting)) {
- content.setting.forEach(setList => {
- if (setList && !Object.hasOwn(setList, 'isSalesCallAdded')) {
- this.$set(setList, 'isSalesCallAdded', false);
- }
- if (setList && !Object.hasOwn(setList, 'isUserNameCallAdded')) {
- this.$set(setList, 'isUserNameCallAdded', false);
- }
- });
- }
- });
- }
- });
- }
- this.form.list.forEach(e => e.newDay = e.dayNum)
- this.dayList = JSON.parse(JSON.stringify(this.form.list));
- this.videoList.push([]);
- this.addTag = [];
- this.setting.forEach(item => {
- if (item && Array.isArray(item.content)) {
- item.content.forEach(content => {
- this.addTag.push({
- addTag: content.addTag ? JSON.parse(content.addTag) : [],
- inputVisible: false,
- inputValue: '',
- delTag: content.delTag ? JSON.parse(content.delTag) : [],
- delTagVisible: false,
- delTagValue: ''
- });
- });
- }
- });
- // this.addTag.push({
- // addTag: [],
- // inputVisible: false,
- // inputValue: '',
- // delTag: [],
- // delTagVisible: false,
- // delTagValue: ''
- // })
- });
- },
- /** 提交按钮 */
- submitForm() {
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids;
- this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function () {
- return delSopTemp(ids);
- }).then(() => {
- this.getList();
- this.msgSuccess("删除成功");
- }).catch(() => {
- });
- },
- /** 导出按钮操作 */
- handleExport() {
- const queryParams = this.queryParams;
- this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- this.exportLoading = true;
- return exportSopTemp(queryParams);
- }).then(response => {
- this.download(response.msg);
- this.exportLoading = false;
- }).catch(() => {
- });
- },
- updateHtml(val,content) {
- val || val();
- if(!!content && !!content.liveId ){
- content.liveId = null;
- }
- },
- updateAll(setIndex, list, fieldName, newVal) {
- if(this.form.sendType == 11 && setIndex == 0) {
- console.info("更新数据", newVal)
- for (let index in list.content) {
- this.$set(list.content[index].setting[0], fieldName, newVal);
- }
- }
- }
- }
- };
- </script>
|