indexNew.vue 53 KB

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