template.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="auxiliary-Smart-call-out-template-container layout-pd">
  3. <el-card shadow="never">
  4. <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent>
  5. <el-form-item label="模板标题" prop="Label">
  6. <el-input v-model="state.queryParams.Label" placeholder="请输入模板标题" clearable @keyup.enter="handleQuery" class="keyword-input" />
  7. </el-form-item>
  8. <el-form-item label="创建时间" prop="crTime">
  9. <el-date-picker
  10. v-model="state.queryParams.crTime"
  11. type="datetimerange"
  12. unlink-panels
  13. range-separator="至"
  14. start-placeholder="开始时间"
  15. end-placeholder="结束时间"
  16. :shortcuts="shortcuts"
  17. @change="timeStartChangeCr"
  18. value-format="YYYY-MM-DD[T]HH:mm:ss"
  19. />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  23. <el-button @click="resetQuery(ruleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
  24. </el-form-item>
  25. </el-form>
  26. </el-card>
  27. <el-card shadow="never">
  28. <!-- 表格 -->
  29. <ProTable
  30. ref="proTableRef"
  31. :columns="columns"
  32. :data="state.tableData"
  33. @updateTable="queryList"
  34. :loading="state.loading"
  35. :total="state.total"
  36. v-model:page-index="state.queryParams.PageIndex"
  37. v-model:page-size="state.queryParams.PageSize"
  38. >
  39. <template #tableHeader="scope">
  40. <el-button type="primary" @click="onAdd" v-auth="'auxiliary:smartCallOut:tem:add'">
  41. <SvgIcon name="ele-Plus" class="mr5" /> 新增模板
  42. </el-button>
  43. </template>
  44. <!-- 表格操作 -->
  45. <template #operation="{ row }">
  46. <el-button link type="primary" @click="onEdit(row)" v-auth="'auxiliary:smartCallOut:tem:edit'" title="编辑模板"> 编辑 </el-button>
  47. <el-button link type="primary" @click="onDelete(row)" v-auth="'auxiliary:smartCallOut:tem:delete'" title="删除模板"> 删除 </el-button>
  48. </template>
  49. </ProTable>
  50. </el-card>
  51. <!-- 新增模板 -->
  52. <tem-add ref="temAddRef" @updateList="queryList" />
  53. <!-- 编辑模板 -->
  54. <tem-edit ref="temEditRef" @updateList="queryList" />
  55. </div>
  56. </template>
  57. <script lang="tsx" setup name="auxiliarySmartCallOutTemplate">
  58. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  59. import { ElButton, ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  60. import { formatDate } from '@/utils/formatTime';
  61. import { citizenDelete, citizenList } from '@/api/auxiliary/citizen';
  62. import { shortcuts } from '@/utils/constants';
  63. import { auth } from "@/utils/authFunction";
  64. // 引入组件
  65. const TemAdd = defineAsyncComponent(() => import('@/views/auxiliary/smartCallOut/components/Tem-add.vue')); // 新建模板
  66. const TemEdit = defineAsyncComponent(() => import('@/views/auxiliary/smartCallOut/components/Tem-edit.vue')); // 编辑标签
  67. const proTableRef = ref<RefType>(); // 表格ref
  68. // 表格配置项
  69. const columns = ref<any[]>([
  70. { prop: 'phoneNumber', label: '标题'},
  71. { prop: 'label', label: '关联外呼任务'},
  72. {
  73. prop: 'isEnable',
  74. label: '是否启用',
  75. render: (scope) => {
  76. return (
  77. <>
  78. {auth('quality:template:edit') ? (
  79. <el-switch
  80. model-value={scope.row.isEnable}
  81. active-text="启用"
  82. inactive-text="禁用"
  83. active-value={1}
  84. inactive-value={0}
  85. onClick={() => changeIsEnable(scope.row)}
  86. inline-prompt
  87. />
  88. ) : (
  89. <span>{scope.row.isEnable === 1 ? '启用' : '禁用'}</span>
  90. )}
  91. </>
  92. );
  93. },
  94. },
  95. { prop: 'creatorName', label: '创建人' },
  96. { prop: 'creatorName', label: '创建部门' },
  97. {
  98. prop: 'creationTime',
  99. label: '创建时间',
  100. width: 170,
  101. render: (scope) => {
  102. return <span>{formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  103. },
  104. },
  105. { prop: 'operation', label: '操作', fixed: 'right', width: 140, align: 'center' },
  106. ]);
  107. // 定义变量内容
  108. const state = reactive({
  109. loading: false, // 加载状态
  110. queryParams: {
  111. // 查询参数
  112. PageIndex: 1,
  113. PageSize: 10,
  114. PhoneNumber: null,
  115. Label: null,
  116. },
  117. total: 0, // 总条数
  118. tableData: [], // 表格数据
  119. });
  120. const ruleFormRef = ref<RefType>(null); // 表单ref
  121. /** 搜索按钮操作 */
  122. const handleQuery = () => {
  123. state.queryParams.PageIndex = 1;
  124. queryList();
  125. };
  126. const handleTimeChange = (val: string[], startKey: string, endKey: string) => {
  127. if (val) {
  128. state.queryParams[startKey] = val[0];
  129. state.queryParams[endKey] = val[1];
  130. } else {
  131. state.queryParams[startKey] = null;
  132. state.queryParams[endKey] = null;
  133. }
  134. handleQuery();
  135. };
  136. // 创建时间
  137. const timeStartChangeCr = (val: string[]) => {
  138. handleTimeChange(val, 'StartTime', 'EndTime');
  139. queryList();
  140. };
  141. // 获取列表
  142. const queryList = () => {
  143. /*state.loading = true;
  144. citizenList(state.queryParams)
  145. .then((res) => {
  146. state.loading = false;
  147. state.tableData = res.result.items ?? [];
  148. state.total = res.result.total ?? 0;
  149. })
  150. .finally(() => {
  151. state.loading = false;
  152. });*/
  153. };
  154. // 重置表单
  155. const resetQuery = (formEl: FormInstance | undefined) => {
  156. if (!formEl) return;
  157. formEl.resetFields();
  158. queryList();
  159. };
  160. // 新增模板
  161. const temAddRef = ref<RefType>();
  162. const onAdd = (row: any) => {
  163. temAddRef.value.openDialog();
  164. };
  165. // 编辑模板
  166. const temEditRef = ref<RefType>();
  167. const onEdit = (row: any) => {
  168. temEditRef.value.openDialog(row);
  169. };
  170. // 删除模板
  171. const onDelete = (row: any) => {
  172. ElMessageBox.confirm('确定要删除当前模板?', '提示', {
  173. confirmButtonText: '确定',
  174. cancelButtonText: '取消',
  175. type: 'warning',
  176. }).then(() => {
  177. }).catch(()=>{
  178. })
  179. };
  180. // 启用和禁用
  181. const changeIsEnable = (row: any) => {
  182. ElMessageBox.confirm(`您确定要${row.isEnable === 1 ? '禁用' : '启用'}:【${row.name}】模板,是否继续?`, '提示', {
  183. confirmButtonText: '确认',
  184. cancelButtonText: '取消',
  185. type: 'warning',
  186. draggable: true,
  187. cancelButtonClass: 'default-button',
  188. autofocus: false,
  189. })
  190. .then(() => {
  191. // const isEnable = row.isEnable === 1 ? 0 : 1;
  192. // const request = {
  193. // ...row,
  194. // isEnable: isEnable,
  195. // };
  196. // templateUpdate(request)
  197. // .then(() => {
  198. // ElMessage.success('操作成功');
  199. // queryList();
  200. // })
  201. // .catch(() => {
  202. // queryList();
  203. // });
  204. })
  205. .catch(() => {
  206. });
  207. };
  208. // 页面加载时
  209. onMounted(() => {
  210. queryList();
  211. });
  212. </script>