indexNew.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
  4. <el-form-item label="企微公司" prop="corpId">
  5. <el-select v-model="queryParams.corpId" placeholder="企微公司" size="small" @change="updateCorpId()">
  6. <el-option
  7. v-for="dict in myQwCompanyList"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="使用的成员" >
  15. <el-select v-model="queryParams.qwUserIds" filterable clearable placeholder="公司员工" size="small">
  16. <el-option
  17. v-for="dict in companyUserList"
  18. :key="dict.qwUserId"
  19. :label="dict.nickName"
  20. :value="dict.qwUserId">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="是否开启分时段" prop="isDayparting">
  25. <el-select v-model="queryParams.isDayparting" placeholder="请选择" clearable size="small">
  26. <el-option v-for="dict in allowSelectOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"/>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="创建时间" prop="createdTime">
  30. <el-date-picker clearable size="small"
  31. v-model="queryParams.createdTime"
  32. type="date"
  33. value-format="yyyy-MM-dd"
  34. placeholder="选择创建时间">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item label="更新时间" prop="updateTieme">
  38. <el-date-picker clearable size="small"
  39. v-model="queryParams.updateTieme"
  40. type="date"
  41. value-format="yyyy-MM-dd"
  42. placeholder="选择更新时间">
  43. </el-date-picker>
  44. </el-form-item>
  45. <el-form-item label="是否发送欢迎语" prop="isSendMsg">
  46. <el-select v-model="queryParams.isSendMsg" placeholder="请选择" clearable size="small" >
  47. <el-option v-for="dict in allowSelectOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"/>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  53. <el-button
  54. type="primary"
  55. plain
  56. size="mini"
  57. icon="el-icon-plus"
  58. @click="handleAdd"
  59. v-hasPermi="['qw:friendWelcome:add']"
  60. >新增</el-button>
  61. </el-form-item>
  62. </el-form>
  63. <el-row :gutter="10" class="mb8">
  64. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  65. </el-row>
  66. <el-table v-loading="loading" :data="friendWelcomeList" @selection-change="handleSelectionChange" border>
  67. <el-table-column label="消息内容" align="left" prop="welcomeText" width="400px" >
  68. <template slot-scope="scope">
  69. <span style="color:rgb(19, 154, 50);" v-if="scope.row.isDayparting==='1'">[共 {{JSON.parse(scope.row.daypartingItemlist).length+1}} 时段]</span>
  70. <span style="color:rgb(19, 154, 50);" v-else >[默认时段]</span>
  71. <el-tooltip class="item" effect="dark" :content="scope.row.welcomeText" placement="top">
  72. <div style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
  73. <span>{{ scope.row.welcomeText }}</span>
  74. </div>
  75. </el-tooltip>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="使用成员" align="center" prop="qwUserIds">
  79. <template slot-scope="scope">
  80. <div v-for="id in JSON.parse(scope.row.qwUserIds)" :key="id" style="display: inline;" class="text-container">
  81. <el-tag type="success" v-for="list in companyUserList" :key="list.qwUserId" style="margin: 3px;" v-if="list.id==id">{{list.qwUserName}}</el-tag>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="是否开启分时段" align="center" prop="isDayparting">
  86. <template slot-scope="scope">
  87. <dict-tag :options="allowSelectOptions" :value="scope.row.isDayparting"></dict-tag>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="是否发送欢迎语" align="center" prop="isSendMsg" >
  91. <template slot-scope="scope">
  92. <dict-tag :options="allowSelectOptions" :value="scope.row.isSendMsg"></dict-tag>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  96. <el-table-column label="更新时间" align="center" prop="updateTime" width="180"/>
  97. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px">
  98. <template slot-scope="scope">
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-edit"
  103. @click="handleUpdate(scope.row)"
  104. v-hasPermi="['qw:friendWelcome:edit']"
  105. >修改</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. @click="handleDelete(scope.row)"
  111. v-hasPermi="['qw:friendWelcome:remove']"
  112. >删除</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改好友欢迎语对话框 -->
  124. <el-dialog :title="title" :visible.sync="open" v-loading="loading" width="1700px" append-to-body>
  125. <div style="width: 1130px" class="app-container">
  126. <div>
  127. <span style="font-size: 15px">基础信息</span>
  128. <el-divider></el-divider>
  129. <el-alert
  130. title="注意事项"
  131. type="warning"
  132. description="这是提示~根据特色还不知道写点啥"
  133. :closable="false"
  134. show-icon>
  135. </el-alert>
  136. </div>
  137. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  138. <el-form-item label="选择使用成员:" prop="qwUserIds" style="margin-top: 2%">
  139. <div>
  140. <el-button
  141. size="medium"
  142. icon="el-icon-circle-plus-outline"
  143. plain
  144. @click="handlelistUser">请选择使用成员</el-button>
  145. </div>
  146. <div>
  147. <el-tag
  148. style="margin-left: 5px"
  149. size="medium"
  150. :key="list.id"
  151. v-for="list in userSelectList"
  152. closable
  153. :disable-transitions="false"
  154. @close="handleClosegroupUser(list)">
  155. {{list.qwUserName}}({{list.nickName}})
  156. </el-tag>
  157. </div>
  158. </el-form-item>
  159. <el-form-item label="是否发送欢迎语">
  160. <el-switch
  161. v-model="form.isSendMsg"
  162. active-color="#13ce66"
  163. inactive-color="#ff4949"
  164. active-value="1"
  165. inactive-value="2">
  166. </el-switch>
  167. <span v-if="form.isSendMsg == '1'" style="margin-left: 10px;color: #13ce66">允许</span>
  168. <span v-if="form.isSendMsg == '2'" style="margin-left: 10px;color: #ff4949">不允许</span>
  169. </el-form-item>
  170. <div>
  171. <span style="font-size: 15px">发送欢迎语</span>
  172. <el-divider></el-divider>
  173. </div>
  174. <el-form-item label="默认欢迎语:" prop="welcomeText">
  175. <el-input v-model="form.welcomeText" type="textarea" :rows="12" maxlength="1300" show-word-limit placeholder="请输入消息内容"/>
  176. <!-- 附件和链接列表 -->
  177. <el-row>
  178. <el-col>
  179. <div v-for="(item, index) in form.attachments" :key="index" style="background-color: #f5f7fa;padding: 5px;border: 1px solid #d9d9d9;">
  180. <div slot="header" style="display: flex;justify-content: space-between;align-items: center; ">
  181. <div style="flex: 1;">
  182. <span v-if="item.msgtype === 'image'">【图片】: {{ item.image.pic_url }}</span>
  183. <span v-if="item.msgtype === 'video'">【视频】: {{ item.video.url }}</span>
  184. <span v-if="item.msgtype === 'link'">【链接】: {{ item.link.title }}-{{item.link.desc}}</span>
  185. <span v-if="item.msgtype === 'miniprogram'">【小程序】: {{ item.miniprogram.title }}</span>
  186. </div>
  187. <div style=" display: flex;gap: 10px;">
  188. <el-button
  189. size="mini"
  190. type="text"
  191. icon="el-icon-edit"
  192. style="float: left;"
  193. @click="editFileItem(item,index,-1)"
  194. >修改</el-button>
  195. <el-button
  196. size="mini"
  197. type="text"
  198. icon="el-icon-delete"
  199. style="float: right;"
  200. @click="removeFileItem(item,index,-1)"
  201. >删除</el-button>
  202. </div>
  203. </div>
  204. </div>
  205. </el-col>
  206. </el-row>
  207. <el-dropdown @command="(command) => handleCommand(command, -1)" trigger="click" placement="top-start">
  208. <el-dropdown-menu slot="dropdown" style="width: 120px;">
  209. <el-dropdown-item command="image">
  210. <i class="el-icon-picture" style="margin-right: 10px;"></i>图片
  211. </el-dropdown-item>
  212. <el-dropdown-item command="video">
  213. <i class="el-icon-video-camera" style="margin-right: 10px;"></i>视频
  214. </el-dropdown-item>
  215. <el-dropdown-item command="link">
  216. <i class="el-icon-link" style="margin-right: 10px;"></i>链接
  217. </el-dropdown-item>
  218. <el-dropdown-item command="miniprogram">
  219. <i class="el-icon-link" style="margin-right: 10px;"></i>小程序
  220. </el-dropdown-item>
  221. </el-dropdown-menu>
  222. <span class="el-dropdown-link">
  223. <el-link icon="el-icon-paperclip" type="text" style="color: rgb(24, 144, 255)">
  224. 添加附件(最多9个)
  225. </el-link>
  226. </span>
  227. </el-dropdown>
  228. </el-form-item>
  229. <el-form-item label="分时段欢迎语">
  230. <el-switch
  231. v-model="form.isDayparting"
  232. active-color="#13ce66"
  233. inactive-color="#ff4949"
  234. active-value="1"
  235. inactive-value="2">
  236. </el-switch>
  237. <span v-if="form.isDayparting == '1'" style="margin-left: 10px;color: #13ce66">已启用</span>
  238. <span v-if="form.isDayparting == '2'" style="margin-left: 10px;color: #ff4949">已禁用</span>
  239. </el-form-item>
  240. <el-form-item v-if="form.isDayparting == '1'" >
  241. <div style="background-color:#ecf8fe;width: 100%;border: 1px solid #dcdfe6">
  242. <span style="margin-left:20px;font-size: 15px;display: block" >注意:1、员工上下班不同时间段可设置不同欢迎语;</span>
  243. <span style="margin-left:65px;font-size: 15px;display: block" >2、分时段之外的时间将发送已允许的默认欢迎语。</span>
  244. <span style="margin-left:65px;font-size: 15px;display: block" >3、不设置分时段欢迎语则使用已允许的默认欢迎语</span>
  245. <span style="margin-left:65px;font-size: 15px;display: block" >4、若员工没有设置过欢迎语则不会发送</span>
  246. </div>
  247. </el-form-item>
  248. <el-form-item v-if="form.isDayparting == '2'">
  249. <div style="background-color:#ecf8fe;width: 100%;border: 1px solid #dcdfe6">
  250. <span style="margin-left:20px;font-size: 15px;display: block" >注意:1、新建欢迎语最多可发送1条文字消息和9个附件;</span>
  251. <span style="margin-left:65px;font-size: 15px;display: block" >2、文字消息和附件不能同时为空,当两者均填写时用户会收到多条消息;</span>
  252. <span style="margin-left:65px;font-size: 15px;display: block" >3、欢迎语将在客户加为好友后20秒内下发,因网络延迟可能造成发送不成功</span>
  253. </div>
  254. </el-form-item>
  255. <div v-if="form.isDayparting == '1'" v-for="(item, index) in form.daypartingItemlist" :key="index" >
  256. <el-form-item :label="`时段 ${index + 1}:`">
  257. <el-row>
  258. <el-col style="width: 965px">
  259. <div style="background-color: #fbfbfb;padding: 10px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  260. <el-form ref="friendWelcomeItemForm" :rules="itemRules" :model="item">
  261. <div style="display: flex; gap: 10px;">
  262. <el-form-item label="发起时间:" prop="week" style="flex: 8;">
  263. <el-select v-model="item.week" remote multiple placeholder="请选择" filterable style="width: 580px">
  264. <el-option
  265. v-for="dict in weekOptions"
  266. :key="dict.value"
  267. :label="dict.label"
  268. :value="dict.value">
  269. </el-option>
  270. </el-select>
  271. </el-form-item>
  272. <el-form-item prop="startTime" style="flex: 1;">
  273. <el-time-select style="width: 120px;"
  274. placeholder="起始时间"
  275. v-model="item.startTime"
  276. :picker-options="{
  277. start: '00:00',
  278. step: '00:15',
  279. end: '24:00'
  280. }">
  281. </el-time-select>
  282. </el-form-item>
  283. <el-form-item prop="endTime" style="flex: 1;">
  284. <el-time-select style="width: 120px;"
  285. placeholder="结束时间"
  286. v-model="item.endTime"
  287. :picker-options="{
  288. start: '00:00',
  289. step: '00:15',
  290. end: '24:00',
  291. minTime: item.startTime
  292. }">
  293. </el-time-select>
  294. </el-form-item>
  295. </div>
  296. <el-form-item style="margin-top: 20px" prop="welcomeText">
  297. <el-input v-model="item.welcomeText" type="textarea" :rows="12" maxlength="1300" show-word-limit placeholder="请输入消息内容"/>
  298. <!-- 附件和链接列表 -->
  299. <el-row>
  300. <el-col>
  301. <div v-for="(attachment, attachIndex) in item.attachments" :key="attachIndex" style="background-color: #f5f7fa;padding: 5px;border: 1px solid #d9d9d9;">
  302. <div slot="header" style=" display: flex;justify-content: space-between;align-items: center; ">
  303. <div style="flex: 1;">
  304. <span v-if="attachment.msgtype === 'image'">【图片】: {{ attachment.image.pic_url }}</span>
  305. <span v-if="attachment.msgtype === 'video'">【视频】: {{ attachment.video.url }}</span>
  306. <span v-if="attachment.msgtype === 'link'">【链接】: {{ attachment.link.title }}-{{attachment.link.desc}}</span>
  307. <span v-if="attachment.msgtype === 'miniprogram'">【小程序】: {{ attachment.miniprogram.title }}</span>
  308. </div>
  309. <div style=" display: flex;gap: 10px;">
  310. <el-button
  311. size="mini"
  312. type="text"
  313. icon="el-icon-edit"
  314. style="float: left;"
  315. @click="editFileItem(attachment,attachIndex,index)"
  316. >修改</el-button>
  317. <el-button
  318. size="mini"
  319. type="text"
  320. icon="el-icon-delete"
  321. style="float: right;"
  322. @click="removeFileItem(attachment,attachIndex,index)"
  323. >删除</el-button>
  324. </div>
  325. </div>
  326. </div>
  327. </el-col>
  328. </el-row>
  329. <el-dropdown @command="(command) => handleCommand(command, index)" trigger="click" placement="top-start">
  330. <el-dropdown-menu slot="dropdown" style="width: 120px;">
  331. <el-dropdown-item command="image">
  332. <i class="el-icon-picture" style="margin-right: 10px;"></i>图片
  333. </el-dropdown-item>
  334. <el-dropdown-item command="video">
  335. <i class="el-icon-video-camera" style="margin-right: 10px;"></i>视频
  336. </el-dropdown-item>
  337. <el-dropdown-item command="link">
  338. <i class="el-icon-link" style="margin-right: 10px;"></i>链接
  339. </el-dropdown-item>
  340. <!-- <el-dropdown-item command="miniprogram">-->
  341. <!-- <i class="el-icon-link" style="margin-right: 10px;"></i>小程序-->
  342. <!-- </el-dropdown-item>-->
  343. </el-dropdown-menu>
  344. <span class="el-dropdown-link">
  345. <el-link icon="el-icon-paperclip" type="text" style="color: rgb(24, 144, 255)">
  346. 添加附件(最多9个)
  347. </el-link>
  348. </span>
  349. </el-dropdown>
  350. </el-form-item>
  351. </el-form>
  352. </div>
  353. </el-col>
  354. <el-col style="width: 15px;">
  355. <el-link v-if="form.daypartingItemlist.length>1" icon="el-icon-delete-solid" @click="delItemList(index)" type="text" style="color: rgb(24, 144, 255);margin-top: 350px" ></el-link>
  356. </el-col>
  357. </el-row>
  358. </el-form-item>
  359. </div>
  360. <div v-if="form.isDayparting == '1'" style="margin-left: 10%">
  361. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addItemList()'>添加其他分时段欢迎语</el-link>
  362. </div>
  363. </el-form>
  364. </div>
  365. <div slot="footer" class="dialog-footer" style="text-align: center">
  366. <el-button type="primary" @click="submitForm">确定</el-button>
  367. <el-button @click="cancel">取 消</el-button>
  368. </div>
  369. </el-dialog>
  370. <!-- 选择成员账号弹窗 -->
  371. <el-dialog :title="listUser.title" :visible.sync="listUser.open" style="width: 1600px;height: 100%" append-to-body>
  372. <qwUserList ref="QwUserList" @selectUserList="selectUserList"></qwUserList>
  373. </el-dialog>
  374. <el-dialog :title="welcomeItem.title" :visible.sync="welcomeItem.open" style="width: 1300px;height: 100%" append-to-body>
  375. <el-form ref="fileFrom" :model="fileFrom" :rules="fuleRules" label-width="110px">
  376. <div v-if="welcomeItem.type==='image'">
  377. <el-form-item label="图片:" prop="imagePicUrl">
  378. <ImageUpload v-model="fileFrom.imagePicUrl" type="image" :num="10" :width="150" :height="150" disabled/>
  379. </el-form-item>
  380. </div>
  381. <div v-if="welcomeItem.type==='video'">
  382. <el-form-item label="视频:" prop="videoUrl">
  383. <el-upload
  384. v-model="fileFrom.videoUrl"
  385. class="avatar-uploader"
  386. :action="uploadUrl"
  387. :show-file-list="false"
  388. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, fileFrom)"
  389. :before-upload="beforeAvatarUploadVideo">
  390. <i class="el-icon-plus avatar-uploader-icon"></i>
  391. </el-upload>
  392. {{fileFrom.videoUrl}}
  393. <video v-if="fileFrom.videoUrl"
  394. :src="fileFrom.videoUrl"
  395. controls style="width: 200px;height: 100px">
  396. </video>
  397. </el-form-item>
  398. </div>
  399. <div v-if="welcomeItem.type==='link'">
  400. <el-form-item label="选择课程">
  401. <el-select v-model="fileFrom.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange(fileFrom,welcomeItem.index,welcomeItem.itemIndex)">
  402. <el-option
  403. v-for="dict in courseList"
  404. :key="dict.dictValue"
  405. :label="dict.dictLabel"
  406. :value="parseInt(dict.dictValue)"
  407. />
  408. </el-select>
  409. <el-select v-model="fileFrom.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange(fileFrom, welcomeItem.index, welcomeItem.itemIndex,welcomeItem.type)" >
  410. <el-option
  411. v-for="dict in videoList"
  412. :key="dict.dictValue"
  413. :label="dict.dictLabel"
  414. :value="parseInt(dict.dictValue)"
  415. />
  416. </el-select>
  417. </el-form-item>
  418. <el-form-item label="图文标题:" prop="linkTitle">
  419. <el-input v-model="fileFrom.linkTitle" :rows="2" maxlength="42" show-word-limit placeholder="请输入图文消息标题,最长为42字" />
  420. </el-form-item>
  421. <el-form-item label="图文封面:" prop="linkPicUrl">
  422. <ImageUpload v-model="fileFrom.linkPicUrl" type="image" :num="10" :width="150" :height="150" />
  423. </el-form-item>
  424. <el-form-item label="图文的描述:" prop="linkDesc">
  425. <el-input v-model="fileFrom.linkDesc" :rows="4" maxlength="170" show-word-limit type="textarea" placeholder="请输入内容,,最长为170字" />
  426. </el-form-item>
  427. <div v-if="fileFrom.videoId==null" style="margin-top: 1%">
  428. <el-form-item label="图文链接:" label-width="100px" >
  429. <el-input v-model="fileFrom.linkUrl" placeholder="请输入链接地址" style="width: 90%;"/>
  430. </el-form-item>
  431. </div>
  432. <div v-if="fileFrom.videoId!=null">
  433. <el-form-item label="图文链接:" label-width="100px" >
  434. <el-tag type="warning" v-model="fileFrom.linkUrl='待生成'">选择的课程小节 即为卡片链接地址</el-tag>
  435. </el-form-item>
  436. </div>
  437. <div v-if="fileFrom.videoId!=null">
  438. <el-form-item label="课节过期时间" style="margin-top: 1%" required label-width="110px">
  439. <el-row>
  440. <el-input-number v-model="fileFrom.expiresDays" :min="1" :max="9999" ></el-input-number>
  441. (天)
  442. </el-row>
  443. <el-row>
  444. <span class="tip">默认为30天</span>
  445. </el-row>
  446. </el-form-item>
  447. </div>
  448. <!-- <el-form-item label="图文链接:" prop="linkUrl">-->
  449. <!-- <el-input v-model="fileFrom.linkUrl" :rows="2" placeholder="选择了课程小节会自动设置地址" />-->
  450. <!-- </el-form-item>-->
  451. </div>
  452. <div v-if="welcomeItem.type==='miniprogram'">
  453. <el-form-item label="选择课程">
  454. <el-select v-model="fileFrom.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange(fileFrom,welcomeItem.index,welcomeItem.itemIndex)">
  455. <el-option
  456. v-for="dict in courseList"
  457. :key="dict.dictValue"
  458. :label="dict.dictLabel"
  459. :value="parseInt(dict.dictValue)"
  460. />
  461. </el-select>
  462. <el-select v-model="fileFrom.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange(fileFrom, welcomeItem.index, welcomeItem.itemIndex,welcomeItem.type)" >
  463. <el-option
  464. v-for="dict in videoList"
  465. :key="dict.dictValue"
  466. :label="dict.dictLabel"
  467. :value="parseInt(dict.dictValue)"
  468. />
  469. </el-select>
  470. </el-form-item>
  471. <el-form-item label="小程序标题:" prop="miniprogramTitle">
  472. <el-input v-model="fileFrom.miniprogramTitle" :rows="2" maxlength="64" placeholder="请输入小程序消息标题,最长为64字节" @input="checkByteLength(fileFrom)" />
  473. </el-form-item>
  474. <div v-if="fileFrom.videoId!=null">
  475. <el-form-item label="小程序链接:" label-width="100px" >
  476. <el-tag type="warning" v-model="fileFrom.miniprogramPage='待生成'">选择的课程小节 即为卡片小程序链接地址</el-tag>
  477. </el-form-item>
  478. </div>
  479. <el-form-item label="appid" prop="miniprogramAppid" v-show="false" >
  480. <el-input v-model="fileFrom.miniprogramAppid='wx73f85f8d62769119' " disabled />
  481. </el-form-item>
  482. <div v-if="fileFrom.videoId!=null">
  483. <el-form-item label="课节过期时间" style="margin-top: 1%" required label-width="110px">
  484. <el-row>
  485. <el-input-number v-model="fileFrom.expiresDays" :min="1" :max="9999" ></el-input-number>
  486. (天)
  487. </el-row>
  488. <el-row>
  489. <span class="tip">默认为30天</span>
  490. </el-row>
  491. </el-form-item>
  492. </div>
  493. <!-- <el-form-item label="图文链接:" prop="linkUrl">-->
  494. <!-- <el-input v-model="fileFrom.linkUrl" :rows="2" placeholder="选择了课程小节会自动设置地址" />-->
  495. <!-- </el-form-item>-->
  496. </div>
  497. </el-form>
  498. <div slot="footer" class="dialog-footer" style="text-align: center">
  499. <el-button type="primary" @click="confirmUpload">确定</el-button>
  500. <el-button type="primary" @click="cancelUpload">取消</el-button>
  501. </div>
  502. </el-dialog>
  503. </div>
  504. </template>
  505. <script>
  506. import { listFriendWelcome, getFriendWelcome, delFriendWelcome, addFriendWelcome, updateFriendWelcome, exportFriendWelcome } from "@/api/qw/friendWelcome";
  507. import qwUserList from '@/views/qw/user/qwUserList.vue'
  508. import ImageUploadWeclome from '@/views/qw/friendWelcome/ImageUploadWeclome.vue'
  509. import ImageUpload from '@/views/qw/material/ImageUpload.vue'
  510. import { getQwAllUserList } from '@/api/company/companyUser'
  511. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  512. import {courseList, videoList} from "@/api/qw/sop";
  513. export default {
  514. name: "FriendWelcome",
  515. components: { ImageUpload, qwUserList,ImageUploadWeclome},
  516. data() {
  517. return {
  518. // 遮罩层
  519. loading: true,
  520. // 导出遮罩层
  521. exportLoading: false,
  522. // 选中数组
  523. ids: [],
  524. // 非单个禁用
  525. single: true,
  526. // 非多个禁用
  527. multiple: true,
  528. myQwCompanyList:[],
  529. //选择成员列表
  530. listUser:{
  531. title:"",
  532. open:false
  533. },
  534. //选择成员列表
  535. userSelectList:[],
  536. fileFrom:{
  537. imagePicUrl:null,
  538. linkTitle:null,
  539. linkPicUrl:null,
  540. linkDesc:null,
  541. linkUrl:null,
  542. videoId:null,
  543. courseId:null,
  544. expiresDays:30,
  545. miniprogramTitle:null,
  546. miniprogramPage:null,
  547. miniprogramPicUrl:null,
  548. miniprogramAppid:null,
  549. },
  550. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS2",
  551. courseList:[],
  552. videoList:[],
  553. fuleRules:{
  554. imagePicUrl:[ { required: true, message: "图片不能为空", trigger: "submit" }],
  555. linkTitle:[ { required: true, message: "图文标题不能为空", trigger: "submit" }],
  556. linkUrl:[ { required: true, message: "图文链接不能为空", trigger: "submit" }],
  557. miniprogramTitle:[ { required: true, message: "图文链接不能为空", trigger: "submit" }],
  558. },
  559. weekOptions: [{
  560. value: 1,
  561. label: '星期一'
  562. }, {
  563. value: 2,
  564. label: '星期二'
  565. }, {
  566. value: 3,
  567. label: '星期三'
  568. }, {
  569. value: 4,
  570. label: '星期四'
  571. }, {
  572. value: 5,
  573. label: '星期五'
  574. }
  575. , {
  576. value: 6,
  577. label: '星期六'
  578. }
  579. , {
  580. value: 7,
  581. label: '星期天'
  582. }],
  583. welcomeItem:{
  584. open: false,
  585. title: '',
  586. type: '',
  587. index: -1,
  588. itemIndex: -1
  589. },
  590. // 弹出层标题
  591. title: "",
  592. // 是否显示弹出层
  593. open: false,
  594. //是否
  595. allowSelectOptions:[],
  596. // 显示搜索条件
  597. showSearch: true,
  598. // 总条数
  599. total: 0,
  600. // 好友欢迎语表格数据
  601. friendWelcomeList: [],
  602. //账号列表
  603. companyUserList:[],
  604. // 查询参数
  605. queryParams: {
  606. pageNum: 1,
  607. pageSize: 10,
  608. qwUserIds: [],
  609. companyId: null,
  610. welcomeText: null,
  611. isDayparting: null,
  612. createTime: null,
  613. updateTime: null,
  614. isSendMsg: null,
  615. corpId: null,
  616. },
  617. // 表单参数
  618. form: {},
  619. // 表单校验
  620. rules: {
  621. qwUserIds: [
  622. { required: true, message: "发送企业群发消息的成员账号不能为空", trigger: "submit" }
  623. ],
  624. welcomeText:[
  625. { required: true, message: "消息内容不能为空噢", trigger: "submit" }
  626. ],
  627. },
  628. itemRules: {
  629. week: [
  630. { required: true, message: '请选择发起时间的星期', trigger: 'submit' }
  631. ],
  632. startTime: [
  633. { required: true, message: '请选择开始时间', trigger: 'submit' },
  634. ],
  635. endTime: [
  636. { required: true, message: '请选择结束时间', trigger: 'submit' },
  637. ],
  638. welcomeText: [
  639. { required: true, message: '消息内容不能为空噢', trigger: 'submit' }
  640. ]
  641. }
  642. };
  643. },
  644. created() {
  645. //账号列表
  646. //是否允许发送
  647. this.getDicts("sys_qw_allow_select").then(response => {
  648. this.allowSelectOptions = response.data;
  649. });
  650. courseList().then(response => {
  651. this.courseList = response.list;
  652. });
  653. getMyQwCompanyList().then(response => {
  654. this.myQwCompanyList = response.data;
  655. if(this.myQwCompanyList!=null){
  656. this.queryParams.corpId=this.myQwCompanyList[0].dictValue
  657. getQwAllUserList(this.myQwCompanyList[0].dictValue).then(response => {
  658. this.companyUserList = response.data;
  659. });
  660. this.getList();
  661. }
  662. });
  663. },
  664. watch:{
  665. userSelectList(newList) {
  666. this.form.qwUserIds =newList.map(item =>item.id);
  667. }
  668. },
  669. methods: {
  670. updateCorpId(){
  671. this.getList();
  672. getQwAllUserList(this.queryParams.corpId).then(response => {
  673. this.companyUserList = response.data;
  674. });
  675. },
  676. /** 查询好友欢迎语列表 */
  677. getList() {
  678. this.loading = true;
  679. listFriendWelcome(this.queryParams).then(response => {
  680. // 将处理后的数据赋值给 friendWelcomeList
  681. this.friendWelcomeList = response.rows;
  682. this.total = response.total;
  683. this.loading = false;
  684. });
  685. },
  686. // // 检查字节长度
  687. checkByteLength(fileFrom) {
  688. const text = fileFrom.miniprogramTitle;
  689. const byteLength = this.getByteLength(text); // 获取当前字节数
  690. // 如果字节数超过64,截断输入内容
  691. if (byteLength > 64) {
  692. this.$set(fileFrom, 'miniprogramTitle', this.truncateTextByByteLength(text,64));
  693. }
  694. },
  695. // 计算字符串的字节数
  696. getByteLength(text) {
  697. return new Blob([text]).size; // 使用 Blob 计算字节数
  698. },
  699. // 根据字节数截断字符串
  700. truncateTextByByteLength(text, maxByteLength) {
  701. let byteLength = 0;
  702. let result = "";
  703. for (let i = 0; i < text.length; i++) {
  704. const char = text[i];
  705. const charByteLength = this.getByteLength(char); // 获取当前字符的字节数
  706. // 如果加上当前字符的字节数后不超过限制,则添加到结果中
  707. if (byteLength + charByteLength <= maxByteLength) {
  708. result += char;
  709. byteLength += charByteLength;
  710. } else {
  711. break; // 超过限制时停止
  712. }
  713. }
  714. return result;
  715. },
  716. //选择群发的企业成员账号
  717. handlelistUser(){
  718. setTimeout(() => {
  719. this.$refs.QwUserList.getDetails(this.queryParams.corpId);
  720. }, 1);
  721. this.listUser.title="选择企业成员"
  722. this.listUser.open=true;
  723. },
  724. //选择的成员账号列表
  725. selectUserList(list){
  726. this.listUser.open=false;
  727. // 3. 遍历要添加的 list,逐条判断是否存在重复
  728. list.forEach(newItem => {
  729. // some() 判断是否存在相同 id
  730. const isExist = this.userSelectList.some(oldItem => oldItem.id === newItem.id);
  731. if (!isExist) {
  732. // 不存在重复的,才添加
  733. this.userSelectList.push(newItem);
  734. }
  735. });
  736. // //用于显示
  737. // this.userSelectList=list;
  738. },
  739. //删除一些选择了的账号
  740. handleClosegroupUser(list){
  741. // 假设 list 对象具有一个 id 属性
  742. const index = this.userSelectList.findIndex(t => t.id === list.id);
  743. if (index !== -1) {
  744. this.userSelectList.splice(index,1);
  745. }
  746. },
  747. //附件选择
  748. handleCommand(command,itemIndex){
  749. if (this.form.attachments.length >=9 && itemIndex===-1) {
  750. return this.$message.error('附件数量已达上限,无法添加更多附件');
  751. }
  752. if (this.isDayparting==='1' && this.form.daypartingItemlist[itemIndex].attachments.length>=9){
  753. return this.$message.error('附件数量已达上限,无法添加更多附件');
  754. }
  755. this.welcomeItem = {
  756. open: true,
  757. title: this.getTitleByCommand(command),
  758. type: command,
  759. index: itemIndex === -1 ? this.form.attachments.length : this.form.daypartingItemlist[itemIndex].attachments.length,
  760. itemIndex
  761. };
  762. },
  763. getTitleByCommand(command) {
  764. switch (command) {
  765. case 'image':
  766. return '添加图片';
  767. case 'link':
  768. return '添加链接';
  769. case 'miniprogram':
  770. return '添加小程序';
  771. }
  772. },
  773. courseChange(fileFrom,index,itemIndex){
  774. // 清空 videoId 选择
  775. this.$set(fileFrom, 'videoId', null);
  776. // 清空 videoList
  777. this.videoList = [];
  778. if (fileFrom.courseId != null) {
  779. // 查找选中的课程对应的 label 和 dictImgUrl
  780. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === fileFrom.courseId);
  781. if (selectedCourse) {
  782. // 设置 linkTitle 和 linkImageUrl
  783. this.$set(fileFrom, 'linkTitle', selectedCourse.dictLabel);
  784. this.$set(fileFrom, 'linkPicUrl', selectedCourse.dictImgUrl);
  785. }
  786. // 获取新的 videoList
  787. videoList(fileFrom.courseId).then(response => {
  788. this.videoList = response.list;
  789. });
  790. }
  791. //
  792. // // 更新对应的数据层级
  793. // if (itemIndex === -1) {
  794. // // 更新 form.attachments
  795. // this.$set(this.form.attachments, index, {
  796. // ...this.form.attachments[index],
  797. // courseId: fileFrom.courseId,
  798. // videoId: null, // 因为已清空
  799. // title: fileFrom.linkTitle,
  800. // picurl: fileFrom.linkPicUrl
  801. // });
  802. // } else {
  803. //
  804. // this.$set(this.form.daypartingItemlist[itemIndex].attachments, index, {
  805. // ...this.form.daypartingItemlist[itemIndex].attachments[index],
  806. // courseId: fileFrom.courseId,
  807. // videoId: null, // 因为已清空
  808. // title: fileFrom.linkTitle,
  809. // picurl: fileFrom.linkPicUrl
  810. // });
  811. // }
  812. },
  813. videoIdChange(fileFrom,index, itemIndex,type){
  814. //选择了课程小节则 默认绑上
  815. if (fileFrom.videoId != null) {
  816. // 根据 videoId 获取相关信息(假设有相关的 API 调用)
  817. let selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === fileFrom.videoId);
  818. if (selectedVideo && type==='link') {
  819. this.$set(fileFrom, 'linkDesc', selectedVideo.dictLabel);
  820. this.$set(fileFrom, 'expiresDays', 30);
  821. }
  822. if (selectedVideo && type==='miniprogram') {
  823. this.$set(fileFrom, 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel,64));
  824. this.$set(fileFrom, 'expiresDays', 30);
  825. }
  826. }
  827. // // 更新对应的数据层级
  828. // if (itemIndex === -1) {
  829. // // 更新 form.attachments
  830. // this.$set(this.form.attachments, index, {
  831. // ...this.form.attachments[index],
  832. // videoId: fileFrom.videoId,
  833. // desc: fileFrom.linkDesc,
  834. // });
  835. // } else {
  836. // // 更新 form.daypartingItemlist[itemIndex].attachments
  837. // this.$set(this.form.daypartingItemlist[itemIndex].attachments, index, {
  838. // ...this.form.daypartingItemlist[itemIndex].attachments[index],
  839. // videoId: fileFrom.videoId,
  840. // desc: fileFrom.linkDesc,
  841. // });
  842. //
  843. // }
  844. },
  845. //修改附件
  846. editFileItem(item, index, itemIndex){
  847. this.welcomeItem = {
  848. open: true,
  849. title: this.getEditTitleByMsgType(item.msgtype),
  850. type: item.msgtype,
  851. index,
  852. itemIndex
  853. };
  854. if (item.msgtype === 'image') {
  855. this.fileFrom.imagePicUrl = item.image.pic_url;
  856. } else if (item.msgtype === 'link') {
  857. this.fileFrom.linkTitle = item.link.title;
  858. this.fileFrom.linkPicUrl = item.link.picurl;
  859. this.fileFrom.linkDesc = item.link.desc;
  860. this.fileFrom.linkUrl = item.link.url;
  861. this.fileFrom.videoId = item.link.videoId;
  862. this.fileFrom.courseId = item.link.courseId;
  863. this.fileFrom.expiresDays = item.link.expiresDays;
  864. videoList(item.link.courseId).then(response => {
  865. this.videoList = response.list;
  866. });
  867. }else if (item.msgtype === 'miniprogram') {
  868. this.fileFrom.miniprogramAppid = 'wx73f85f8d62769119';
  869. this.fileFrom.miniprogramTitle = item.miniprogram.title;
  870. this.fileFrom.miniprogramPicUrl = "待生成";
  871. this.fileFrom.miniprogramPage = "待生成";
  872. this.fileFrom.videoId = item.miniprogram.videoId;
  873. this.fileFrom.courseId = item.miniprogram.courseId;
  874. this.fileFrom.expiresDays = item.miniprogram.expiresDays;
  875. videoList(item.miniprogram.courseId).then(response => {
  876. this.videoList = response.list;
  877. });
  878. }
  879. },
  880. getEditTitleByMsgType(msgType) {
  881. switch (msgType) {
  882. case 'image':
  883. return '编辑图片';
  884. case 'link':
  885. return '编辑链接';
  886. case 'miniprogram':
  887. return '编辑小程序';
  888. }
  889. },
  890. //删除附件
  891. removeFileItem(data,index, itemIndex) {
  892. if (itemIndex === -1) {
  893. this.form.attachments.splice(index, 1);
  894. } else {
  895. this.form.daypartingItemlist[itemIndex].attachments.splice(index, 1);
  896. }
  897. },
  898. //添加分时段欢迎语
  899. addItemList(){
  900. this.form.daypartingItemlist.push({welcomeText:null,attachments:[],week:[1,2,3,4,5,6,7],startTime:null,endTime:null})
  901. },
  902. //删除某一个分时段欢迎语
  903. delItemList(index){
  904. this.form.daypartingItemlist.splice(index,1)
  905. },
  906. //提交附件
  907. confirmUpload(fileFrom) {
  908. const { type, index, itemIndex } = this.welcomeItem;
  909. let attachment = {};
  910. if (type === 'image') {
  911. attachment = {
  912. msgtype: 'image',
  913. image: {
  914. pic_url: this.fileFrom.imagePicUrl
  915. }
  916. };
  917. } else if (type === 'link') {
  918. attachment = {
  919. msgtype: 'link',
  920. link: {
  921. title: this.fileFrom.linkTitle,
  922. picurl: this.fileFrom.linkPicUrl,
  923. desc: this.fileFrom.linkDesc,
  924. url: this.fileFrom.linkUrl,
  925. courseId:this.fileFrom.courseId,
  926. videoId:this.fileFrom.videoId,
  927. expiresDays:this.fileFrom.expiresDays,
  928. }
  929. };
  930. }else if (type==='miniprogram'){
  931. attachment = {
  932. msgtype: 'miniprogram',
  933. miniprogram: {
  934. title: this.fileFrom.miniprogramTitle,
  935. pic_media_id: "待查询",
  936. appid: "wx73f85f8d62769119",
  937. page: this.fileFrom.miniprogramPage,
  938. courseId:this.fileFrom.courseId,
  939. videoId:this.fileFrom.videoId,
  940. expiresDays:this.fileFrom.expiresDays,
  941. }
  942. };
  943. }
  944. if (itemIndex === -1) {
  945. // 默认欢迎语附件处理
  946. if (index < this.form.attachments.length) {
  947. // 存在附件则更新
  948. this.form.attachments.splice(index, 1, attachment);
  949. } else {
  950. // 不存在附件则插入
  951. this.form.attachments.push(attachment);
  952. }
  953. } else {
  954. // 分时段欢迎语附件处理
  955. if (index < this.form.daypartingItemlist[itemIndex].attachments.length) {
  956. // 存在附件则更新
  957. this.form.daypartingItemlist[itemIndex].attachments.splice(index, 1, attachment);
  958. } else {
  959. // 不存在附件则插入
  960. this.form.daypartingItemlist[itemIndex].attachments.push(attachment);
  961. }
  962. }
  963. this.resetFileFrom();
  964. },
  965. //取消附件
  966. cancelUpload() {
  967. this.resetFileFrom();
  968. this.welcomeItem.open = false;
  969. },
  970. // 取消按钮
  971. cancel() {
  972. this.open = false;
  973. this.reset();
  974. },
  975. //重置附件表单
  976. resetFileFrom() {
  977. this.fileFrom = {
  978. imagePicUrl: null,
  979. linkTitle: null,
  980. linkPicUrl: null,
  981. linkDesc: null,
  982. linkUrl: null,
  983. videoId:null,
  984. courseId:null,
  985. miniprogramTitle:null,
  986. miniprogramPage:null,
  987. miniprogramPicUrl:null,
  988. miniprogramAppid:null,
  989. };
  990. this.welcomeItem={
  991. open: false,
  992. title: '',
  993. type: '',
  994. index: -1,
  995. itemIndex: -1
  996. } // 重置编辑索引
  997. this.videoList=[];
  998. },
  999. // 表单重置
  1000. reset() {
  1001. this.form = {
  1002. id: null,
  1003. qwUserIds: [],
  1004. companyId: null,
  1005. //默认欢迎语附件
  1006. attachments: [],
  1007. createdTime: null,
  1008. updateTieme: null,
  1009. isSendMsg:'1',
  1010. welcomeText: '',
  1011. isDayparting: '2',
  1012. //分时段欢迎语
  1013. daypartingItemlist:[{welcomeText:null,attachments:[],week:[1,2,3,4,5,6,7],startTime:null,endTime:null}],
  1014. };
  1015. this.userSelectList=[]
  1016. this.resetForm("form");
  1017. },
  1018. /** 搜索按钮操作 */
  1019. handleQuery() {
  1020. this.queryParams.pageNum = 1;
  1021. this.getList();
  1022. },
  1023. /** 重置按钮操作 */
  1024. resetQuery() {
  1025. this.resetForm("queryForm");
  1026. this.queryParams.corpId= this.myQwCompanyList[0].dictValue
  1027. getQwAllUserList(this.queryParams.corpId).then(response => {
  1028. this.companyUserList = response.data;
  1029. });
  1030. this.handleQuery();
  1031. },
  1032. // 多选框选中数据
  1033. handleSelectionChange(selection) {
  1034. this.ids = selection.map(item => item.id)
  1035. this.single = selection.length!==1
  1036. this.multiple = !selection.length
  1037. },
  1038. /** 新增按钮操作 */
  1039. handleAdd() {
  1040. this.reset();
  1041. this.open = true;
  1042. this.title = "新建好友欢迎语";
  1043. },
  1044. /** 修改按钮操作 */
  1045. handleUpdate(row) {
  1046. this.reset();
  1047. const id = row.id || this.ids
  1048. getFriendWelcome(id).then(response => {
  1049. let data = response.row;
  1050. // 转换 attachments
  1051. if (typeof data.attachments === 'string') {
  1052. data.attachments = JSON.parse(data.attachments);
  1053. }
  1054. // 转换 daypartingItemlist
  1055. if (typeof data.daypartingItemlist === 'string') {
  1056. data.daypartingItemlist = JSON.parse(data.daypartingItemlist);
  1057. }
  1058. // 转换 daypartingItemlist 中的每个项目的 attachments 和 week
  1059. if (Array.isArray(data.daypartingItemlist)) {
  1060. data.daypartingItemlist = data.daypartingItemlist.map(item => {
  1061. return {
  1062. ...item,
  1063. attachments: typeof item.attachments === 'string' ? JSON.parse(item.attachments) : item.attachments,
  1064. week: typeof item.week === 'string' ? JSON.parse(item.week) : item.week
  1065. };
  1066. });
  1067. }
  1068. // 赋值给表单
  1069. this.form = data;
  1070. this.userSelectList=this.form.userSelectList
  1071. this.open = true;
  1072. this.title = "修改好友欢迎语";
  1073. });
  1074. },
  1075. /** 提交按钮 验证 from表单*/
  1076. submitForm() {
  1077. this.loading=true;
  1078. this.$refs["form"].validate(valid => {
  1079. if (valid) {
  1080. this.form.corpId=this.queryParams.corpId;
  1081. //有分时段欢迎语 验证分时段表单
  1082. if (this.form.isDayparting==='1'){
  1083. const itemForms = this.$refs.friendWelcomeItemForm;
  1084. if (Array.isArray(itemForms)) {
  1085. let allValid = true;
  1086. itemForms.forEach((itemFormRef, index) => {
  1087. itemFormRef.validate((itemValid) => {
  1088. if (!itemValid) {
  1089. this.loading=false;
  1090. allValid = false;
  1091. } else {
  1092. const { startTime, endTime } = itemFormRef.model;
  1093. if (startTime && endTime && startTime > endTime) {
  1094. this.$message.error(`时段 ${index + 1} 的开始时间不能大于结束时间`);
  1095. allValid = false;
  1096. this.loading=false;
  1097. }
  1098. }
  1099. if (index === itemForms.length - 1 && allValid) {
  1100. //全表单验证通过
  1101. this.commitForm();
  1102. }
  1103. });
  1104. });
  1105. }
  1106. }else {
  1107. //只有默认的
  1108. this.commitForm();
  1109. }
  1110. }
  1111. });
  1112. },
  1113. //提交form表单
  1114. commitForm(){
  1115. // 深拷贝表单数据
  1116. const requestData = { ...this.form };
  1117. // 将 `form.attachments` 转为 JSON 字符串
  1118. requestData.attachments = JSON.stringify(this.form.attachments);
  1119. requestData.qwUserIds = JSON.stringify(this.form.qwUserIds);
  1120. // 遍历 `daypartingItemlist`,将其中的 `attachments` 和 `week` 转为 JSON 字符串
  1121. requestData.daypartingItemlist = JSON.stringify(requestData.daypartingItemlist.map(item => ({
  1122. ...item,
  1123. }))
  1124. );
  1125. if (this.form.id != null) {
  1126. updateFriendWelcome(requestData).then(response => {
  1127. this.msgSuccess("修改成功");
  1128. this.loading=false;
  1129. this.open = false;
  1130. this.getList();
  1131. }).catch(error => {
  1132. this.open=false;
  1133. this.loading = false;
  1134. });
  1135. } else {
  1136. addFriendWelcome(requestData).then(response => {
  1137. this.msgSuccess("新增成功");
  1138. this.loading=false;
  1139. this.open = false;
  1140. this.getList();
  1141. }).catch(error => {
  1142. this.open=false;
  1143. this.loading = false;
  1144. });
  1145. }
  1146. // 重置表单 无论成功还是失败-都重置表单
  1147. this.reset();
  1148. },
  1149. //处理时间
  1150. // formatTime(date) {
  1151. // const hours = date.getHours().toString().padStart(2, '0');
  1152. // const minutes = date.getMinutes().toString().padStart(2, '0');
  1153. // const seconds = date.getSeconds().toString().padStart(2, '0');
  1154. // return `${hours}:${minutes}:${seconds}`;
  1155. // },
  1156. /** 删除按钮操作 */
  1157. handleDelete(row) {
  1158. const ids = row.id || this.ids;
  1159. this.$confirm('是否确认删除好友欢迎语编号为"' + ids + '"的数据项?', "警告", {
  1160. confirmButtonText: "确定",
  1161. cancelButtonText: "取消",
  1162. type: "warning"
  1163. }).then(function() {
  1164. return delFriendWelcome(ids);
  1165. }).then(() => {
  1166. this.getList();
  1167. this.msgSuccess("删除成功");
  1168. }).catch(() => {});
  1169. },
  1170. /** 导出按钮操作 */
  1171. handleExport() {
  1172. const queryParams = this.queryParams;
  1173. this.$confirm('是否确认导出所有好友欢迎语数据项?', "警告", {
  1174. confirmButtonText: "确定",
  1175. cancelButtonText: "取消",
  1176. type: "warning"
  1177. }).then(() => {
  1178. this.exportLoading = true;
  1179. return exportFriendWelcome(queryParams);
  1180. }).then(response => {
  1181. this.download(response.msg);
  1182. this.exportLoading = false;
  1183. }).catch(() => {});
  1184. },
  1185. handleAvatarSuccessVideo(res, file, content) {
  1186. if (res.code == 200) {
  1187. // 使用 $set 确保响应式更新
  1188. this.$set(content, 'videoUrl', res.url);
  1189. } else {
  1190. this.msgError(res.msg);
  1191. }
  1192. },
  1193. beforeAvatarUploadVideo(file) {
  1194. const isLt30M = file.size / 1024 / 1024 < 10;
  1195. const isMP4 = file.type === 'video/mp4';
  1196. if (!isMP4) {
  1197. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  1198. return false;
  1199. }
  1200. if (!isLt30M) {
  1201. this.$message.error('上传大小不能超过 10MB!');
  1202. return false;
  1203. }
  1204. return true;
  1205. },
  1206. }
  1207. };
  1208. </script>
  1209. <style>
  1210. .text-container {
  1211. max-height: 7.5em; /* 设置最大高度为6行,根据字体大小调整 */
  1212. overflow-y: auto; /* 内容超出时显示滚动条 */
  1213. line-height: 1.5em; /* 行高设置,确保每行高度一致 */
  1214. }
  1215. </style>