TemplateLibrary.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="left pad20" style="border-radius: 4px; background: #fff">
  3. <!--模板库 -->
  4. <div>
  5. <!-- v-hasPermi="['wecom:tlp:add']" -->
  6. <el-form label-position="left" inline label-width="80px">
  7. <el-form-item>
  8. <el-input
  9. :placeholder="isGroup ? '请输入群发内容' : '请输入欢迎语'"
  10. v-model="query.templateInfo"
  11. style="width: 260px"></el-input>
  12. </el-form-item>
  13. <el-form-item label-width="0">
  14. <el-button type="primary" @click="getList(0)">查询</el-button>
  15. <el-button @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. <div>
  20. <el-table v-loading="loading" :data="list" @current-change="currentChange">
  21. <el-table-column width="60">
  22. <template slot-scope="{ row }">
  23. <i
  24. v-if="welSelected ? welSelected.id === row.id : false"
  25. class="el-icon-check"
  26. style="color: rgb(65, 133, 244); font-size: 25px"></i>
  27. </template>
  28. </el-table-column>
  29. <el-table-column :label="isGroup ? '群发内容' : '欢迎语'" align="center" min-width="250" show-overflow-tooltip>
  30. <template slot-scope="scope">
  31. {{ scope.row.templateInfo }}
  32. </template>
  33. </el-table-column>
  34. <!-- <el-table-column
  35. v-if="type === '2'"
  36. label="员工"
  37. prop="userNames"
  38. align="center"
  39. ></el-table-column> -->
  40. <el-table-column label="附件" align="center" prop="attachTotalNum" />
  41. <el-table-column label="最近更新" align="center">
  42. <template slot-scope="scope">
  43. <div>{{ scope.row.updateBy }}</div>
  44. <span>{{ scope.row.createTime }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  48. <template slot-scope="scope">
  49. <el-button size="mini" type="text" @click="showPreview(scope.row)">预览</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <div class="bottom">
  54. <pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList()" />
  55. </div>
  56. </div>
  57. <el-dialog title="预览" :visible.sync="showPreviewDialog" width="50%" append-to-body>
  58. <div>
  59. <PreviewInPhone :list="previewList" :templateInfo="templateInfo"></PreviewInPhone>
  60. </div>
  61. <span slot="footer" class="dialog-footer">
  62. <el-button type="primary" @click="showPreviewDialog = false">关闭</el-button>
  63. </span>
  64. </el-dialog>
  65. <!-- 批量新建弹窗 -->
  66. <SelectWeUser
  67. :visible.sync="dialogVisible"
  68. title="组织架构"
  69. :defaultValues="userArray"
  70. @success="getSelectUser"></SelectWeUser>
  71. </div>
  72. </template>
  73. <script>
  74. import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
  75. import { getList } from '@/api/drainageCode/welcome'
  76. // import { lexicalDetail } from '@/api/contentCenter/scriptCenter'
  77. import { templateDetail } from '@/api/contentCenter/modleCenter'
  78. export default {
  79. name: 'Tab2',
  80. components: {
  81. PreviewInPhone,
  82. },
  83. props: {
  84. type: {
  85. type: Number | String,
  86. default: '1',
  87. },
  88. // 1.欢迎语模板 2.群发模板 3.sop
  89. isGroup: {
  90. type: Boolean,
  91. default: false,
  92. },
  93. },
  94. data() {
  95. return {
  96. welSelected: {
  97. id: '',
  98. },
  99. userArray: [], // 选择人员
  100. qrUserName: undefined,
  101. ids: [],
  102. // 查询参数
  103. query: {
  104. pageNum: 1,
  105. pageSize: 10,
  106. templateType: 1,
  107. // welcomeMsg: undefined,
  108. // orderByColumn: 'wmt.create_time',
  109. // isAsc: 'desc',
  110. },
  111. dialogVisible: false,
  112. loading: false,
  113. total: 0,
  114. list: [],
  115. showPreviewDialog: false,
  116. previewList: [],
  117. templateInfo: '',
  118. materialMsgList: [],
  119. }
  120. },
  121. watch: {},
  122. computed: {},
  123. created() {
  124. this.getList()
  125. },
  126. mounted() {},
  127. methods: {
  128. currentChange(val) {
  129. this.welSelected = val
  130. if (val) {
  131. this.$emit('changeObj', val.id)
  132. // templateDetail(val.id).then((res) => {
  133. // this.$emit('changeObj', res.data)
  134. // })
  135. }
  136. },
  137. resetQuery() {
  138. this.query.templateInfo = ''
  139. this.userArray = []
  140. this.qrUserName = ''
  141. this.query.pageNum = 1
  142. this.getList()
  143. },
  144. getSelectUser(data) {
  145. this.userArray = data
  146. this.qrUserName = this.userArray
  147. .map(function (obj, index) {
  148. return obj.name
  149. })
  150. .join(',')
  151. this.query.qrUserIds = this.userArray
  152. .map(function (obj, index) {
  153. return obj.userId
  154. })
  155. .join(',')
  156. },
  157. handleSelectionChange(selection) {
  158. this.ids = selection.map((item) => item.id)
  159. },
  160. /** 查询 */
  161. getList(page) {
  162. page && (this.query.pageNum = page)
  163. this.loading = true
  164. this.query.templateType = this.isGroup ? 2 : 1
  165. getList(this.query)
  166. .then(({ rows, total }) => {
  167. this.list = rows
  168. this.total = +total
  169. this.loading = false
  170. })
  171. .catch(() => {
  172. this.loading = false
  173. })
  174. },
  175. showPreview(data) {
  176. this.templateInfo = data.templateInfo
  177. this.getDeatil(data.id)
  178. this.showPreviewDialog = true
  179. },
  180. getDeatil(id) {
  181. this.loading = true
  182. templateDetail(id)
  183. .then((res) => {
  184. this.previewList = res.data.weMaterialList
  185. this.loading = false
  186. })
  187. .catch(() => {
  188. this.loading = false
  189. })
  190. },
  191. setEditList(list) {
  192. let arr = []
  193. if (list && list.length) {
  194. list.forEach((dd) => {
  195. if (dd.msgType === 'image') {
  196. let obj = {
  197. msgType: '0',
  198. materialUrl: dd.picUrl,
  199. }
  200. arr.push(obj)
  201. } else if (dd.msgType === 'link') {
  202. let ob = {
  203. msgType: '8',
  204. materialName: dd.title,
  205. materialUrl: dd.linkUrl,
  206. }
  207. arr.push(ob)
  208. } else if (dd.msgType === 'miniprogram') {
  209. let ff = {
  210. msgType: '9',
  211. digest: dd.appId,
  212. materialName: dd.title,
  213. coverUrl: dd.picUrl,
  214. materialUrl: dd.linkUrl,
  215. }
  216. arr.push(ff)
  217. }
  218. })
  219. }
  220. return arr
  221. },
  222. },
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .header {
  227. padding: 0 20px;
  228. }
  229. .divider-content {
  230. width: 100%;
  231. height: 10px;
  232. background-color: #f5f7fb;
  233. }
  234. .bottom {
  235. display: flex;
  236. justify-content: flex-end;
  237. align-items: center;
  238. }
  239. </style>