企微助手 ,仓库名 短剧

index.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div v-loading="loading" class="inviteRuleList-wrap">
  3. <div class="screenBox" style="align-items: center; padding-right: 16px">
  4. <div class="flex-align-center" style="flex: 1">
  5. <!-- 搜索配置 -->
  6. <self-input
  7. style="width: auto"
  8. label_name="关键词"
  9. :hasLabel="false"
  10. :noMarLeft="true"
  11. @inputChange="
  12. (val) => {
  13. keyword = val;
  14. init(1);
  15. }
  16. "
  17. />
  18. <!-- 关联客服 -->
  19. <serviceSingle
  20. style="width: auto"
  21. title="群主"
  22. placeholder="请选择"
  23. @customerDefine="onChangeUser"
  24. />
  25. <!-- 状态 -->
  26. <selfChannelV2
  27. v-model="status"
  28. type="enableStatus"
  29. title="规则状态"
  30. :labelWidth="true"
  31. @change="onChangeStatus"
  32. />
  33. </div>
  34. <el-button type="primary" size="mini" @click="createdMassMsg"
  35. >新建配置</el-button
  36. >
  37. </div>
  38. <div class="tableInfo">
  39. <div>
  40. <div class="flex">
  41. <div class="totalCustom">
  42. 共有<span>{{ total }}</span
  43. >条数据
  44. </div>
  45. </div>
  46. </div>
  47. <div class="flex">
  48. <el-button type="primary" plain size="mini" @click="init(1, 'export')"
  49. >导出Excel</el-button
  50. >
  51. </div>
  52. </div>
  53. <!-- table -->
  54. <el-table
  55. ref="multipleTable"
  56. :height="height"
  57. :data="tableData"
  58. tooltip-effect="dark"
  59. style="width: 100%"
  60. >
  61. <el-table-column
  62. prop="title"
  63. label="标题"
  64. show-overflow-tooltip
  65. align="center"
  66. min-width="140"
  67. fixed="left"
  68. />
  69. <el-table-column
  70. prop="admin_name"
  71. label="创建人"
  72. show-overflow-tooltip
  73. align="center"
  74. min-width="140"
  75. />
  76. <el-table-column label="群名称前缀" align="center" min-width="140" prop="template_group_name" show-overflow-tooltip />
  77. <el-table-column label="配置状态" align="center" min-width="120">
  78. <template slot-scope="{ row }">
  79. <el-switch
  80. v-if="row.status !== ''"
  81. v-model="row.status"
  82. :active-value="1"
  83. :inactive-value="0"
  84. disabled
  85. @click.native="onClickStatus(row)"
  86. />
  87. <div v-else>-</div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column
  91. min-width="140"
  92. label="操作"
  93. align="center"
  94. fixed="right"
  95. >
  96. <template slot-scope="scope">
  97. <div class="flex" style="justify-content: center">
  98. <div
  99. class="c-00B38A pointer table_button"
  100. @click="goDetail(scope.row)"
  101. >
  102. 编辑
  103. </div>
  104. <el-popconfirm
  105. @confirm="deleEvent(scope.row)"
  106. :title="`确定删除【${scope.row.title}】?`"
  107. >
  108. <div slot="reference" class="c-FF604D pointer table_button">
  109. 删除
  110. </div>
  111. </el-popconfirm>
  112. </div>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <div class="pagination" v-show="total > 0">
  117. <el-pagination
  118. background
  119. :current-page="page"
  120. @current-change="handleCurrentChange"
  121. layout="prev, pager, next"
  122. :page-count="Number(pages)"
  123. />
  124. </div>
  125. <el-drawer size="1200px" :visible.sync="massMsgFlag" :with-header="false">
  126. <createData
  127. v-if="massMsgFlag"
  128. ref="createMassMsg"
  129. :rule_id="detail_rule_id"
  130. :title="detail_rule_id ? '配置详情' : '新建配置'"
  131. @close="detailClose"
  132. />
  133. </el-drawer>
  134. </div>
  135. </template>
  136. <script>
  137. import createData from "./setConfig.vue";
  138. import selfInput from "@/components/assembly/screen/input.vue";
  139. import serviceSingle from "@/components/assembly/screen/serviceSingle.vue";
  140. import selfChannelV2 from "@/components/assembly/screen/channelV2.vue";
  141. export default {
  142. components: {
  143. selfInput,
  144. createData,
  145. serviceSingle,
  146. selfChannelV2,
  147. },
  148. data() {
  149. return {
  150. massMsgFlag: false,
  151. loading: false,
  152. page: 1,
  153. pages: 0,
  154. total: 0,
  155. page_size: 20,
  156. tableData: [],
  157. height: "",
  158. detail_rule_id: "",
  159. keyword: "",
  160. user_id: "",
  161. status: "",
  162. };
  163. },
  164. created() {
  165. this.height = document.documentElement.clientHeight - 290;
  166. this.init(1);
  167. },
  168. methods: {
  169. //删除
  170. deleEvent(row) {
  171. this.$loading(this.$loadingConfig);
  172. this.$axios
  173. .post(this.URL.BASEURL + this.URL.create_chat_group_config_del, {
  174. rule_id: row.rule_id,
  175. })
  176. .then((res) => {
  177. this.$loading(this.$loadingConfig).close();
  178. var res = res.data;
  179. if (res && res.errno == 0) {
  180. this.init(1);
  181. }
  182. this.$message({
  183. message: res.err,
  184. type: "warning",
  185. });
  186. });
  187. },
  188. //重置
  189. handleRefresh(row) {
  190. this.$loading(this.$loadingConfig);
  191. this.$axios
  192. .get(this.URL.BASEURL + this.URL.inviteRule_reset, {
  193. params: {
  194. rule_id: row.rule_id,
  195. },
  196. })
  197. .then((res) => {
  198. this.$loading(this.$loadingConfig).close();
  199. var res = res.data;
  200. if (res && res.errno == 0) {
  201. this.$message({
  202. message: '重置成功',
  203. type: "success",
  204. });
  205. this.init(this.page);
  206. } else {
  207. this.$message({
  208. message: res.err,
  209. type: "warning",
  210. });
  211. }
  212. });
  213. },
  214. detailClose(val) {
  215. if (val == "update") {
  216. //编辑
  217. this.init(this.page);
  218. } else if (val == "update_new") {
  219. //复制或者新建
  220. this.init(1);
  221. this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
  222. }
  223. this.massMsgFlag = false;
  224. },
  225. createdMassMsg() {
  226. this.detail_rule_id = "";
  227. this.massMsgFlag = true;
  228. },
  229. goDetail(data) {
  230. this.detail_rule_id = data.rule_id;
  231. this.massMsgFlag = true;
  232. },
  233. // 监听点击切换"状态"
  234. async onClickStatus(row) {
  235. try {
  236. await this.$confirm(
  237. `确定${row.status == 0 ? "启用" : "禁用"}【${row.title}】?`,
  238. "提示",
  239. {
  240. confirmButtonText: "确定",
  241. cancelButtonText: "取消",
  242. type: "warning",
  243. }
  244. );
  245. this.handleChangeStatus(row);
  246. } catch (error) {
  247. console.log(error);
  248. }
  249. },
  250. // 执行“切换状态”
  251. async handleChangeStatus({ rule_id, status }) {
  252. try {
  253. this.loading = true;
  254. const url = `${this.URL.BASEURL}${this.URL.create_chat_group_config_change_status}`;
  255. const params = {
  256. rule_id,
  257. status: status == 1 ? 0 : 1,
  258. };
  259. const { data: res = {} } = await this.$axios.post(url, params);
  260. if (res && res.errno == 0) {
  261. this.$message.success("操作成功");
  262. this.init();
  263. } else if (res.errno != 4002) {
  264. this.$message.warning(res.err);
  265. }
  266. } catch (error) {
  267. console.log(error);
  268. } finally {
  269. this.loading = false;
  270. }
  271. },
  272. init(page, type) {
  273. if (type != "export") {
  274. this.page = page ? page : this.page;
  275. } else {
  276. if (this.total == 0) {
  277. this.$message({
  278. message: "暂无数据可导出",
  279. type: "warning",
  280. });
  281. return;
  282. }
  283. }
  284. this.loading = true;
  285. this.$axios
  286. .get(this.URL.BASEURL + this.URL.create_chat_group_config_list, {
  287. params: {
  288. page: type == "export" ? 1 : this.page,
  289. page_size:
  290. type == "export"
  291. ? this.$store.state.exportNumber
  292. : this.page_size,
  293. keyword: this.keyword,
  294. user_id: this.user_id,
  295. status: this.status,
  296. },
  297. })
  298. .then((res) => {
  299. var res = res.data;
  300. this.loading = false;
  301. if (res && res.errno == 0) {
  302. if (type == "export") {
  303. this.exportEvent(res.rst.data);
  304. } else {
  305. this.tableData = res.rst.data;
  306. this.total = res.rst.pageInfo.total;
  307. this.pages = res.rst.pageInfo.pages;
  308. }
  309. } else if (res.errno != 4002) {
  310. this.$message.warning(res.err);
  311. }
  312. })
  313. .catch((err) => {
  314. this.loading = false;
  315. });
  316. },
  317. handleCurrentChange(val) {
  318. this.init(val);
  319. },
  320. onChangeUser(val) {
  321. this.user_id = val ? val.user_id : "";
  322. this.init(1);
  323. },
  324. onChangeStatus(val) {
  325. this.status = val;
  326. this.init(1);
  327. },
  328. exportEvent(data) {
  329. let list = data;
  330. let tHeader = ["标题", "创建人", "群名称前缀", "规则状态"];
  331. let filterVal = ["title", "admin_name", "template_group_name", "status"];
  332. list.forEach((item) => {
  333. item.status =
  334. item.status == 1 ? "启用" : item.status == 0 ? "禁用" : "-";
  335. });
  336. let excelDatas = [
  337. {
  338. tHeader: tHeader, // sheet表一头部
  339. filterVal: filterVal, // 表一的数据字段
  340. tableDatas: list, // 表一的整体json数据
  341. sheetName: "", // 表一的sheet名字
  342. },
  343. ];
  344. this.$exportOrder({
  345. excelDatas,
  346. name: `邀请入群配置(导出时间:${this.$getDay(0)})`,
  347. });
  348. },
  349. },
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. @import "@/style/list.scss";
  354. .tableInfo {
  355. height: 50px;
  356. }
  357. .table_button {
  358. margin: 0 4px;
  359. min-width: 26px;
  360. }
  361. .inviteRuleList-wrap {
  362. /deep/ .el-switch.is-disabled .el-switch__core {
  363. cursor: pointer;
  364. }
  365. /deep/ .el-switch.is-disabled {
  366. opacity: 1;
  367. }
  368. }
  369. </style>