index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="统一社会信用代码" prop="uniCode" label-width="200">
  5. <el-input
  6. v-model="queryParams.uniCode"
  7. placeholder="请输入统一社会信用代码"
  8. clearable
  9. @keyup.enter="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  14. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="warning"
  21. plain
  22. icon="Download"
  23. @click="handleExport"
  24. :disabled="!xcrAssociationHonorList.length"
  25. v-hasPermi="['basicData:xcrAssociationHonor:export']"
  26. >导出
  27. </el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button
  31. type="info"
  32. plain
  33. icon="Upload"
  34. @click="handleImport"
  35. v-hasPermi="['basicData:xcrAssociationHonor:import']"
  36. >导入
  37. </el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="Delete"
  44. @click="batchDelete"
  45. v-hasPermi="['basicData:xcrAssociationHonor:delete']"
  46. :disabled="ids.length === 0"
  47. >批量删除
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-popconfirm
  52. title="你确定清除所有数据?"
  53. confirm-button-text="是的"
  54. cancel-button-text="不是"
  55. :icon="InfoFilled"
  56. icon-color="#626AEF"
  57. @confirm="handleDelete"
  58. >
  59. <template #reference>
  60. <el-button
  61. type="danger"
  62. plain
  63. icon="Delete"
  64. v-hasPermi="['basicData:honor:delete']"
  65. >清除全表
  66. </el-button>
  67. </template>
  68. </el-popconfirm>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button type="success" plain icon="Download" @click="downloadTemplate">
  72. 下载导入模板
  73. </el-button>
  74. </el-col>
  75. </el-row>
  76. <el-table v-loading="loading" :data="xcrAssociationHonorList" height="650" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center"/>
  78. <el-table-column label="统一社会信用代码" align="center" prop="uniCode" width="200"/>
  79. <el-table-column label="荣誉榜单名称" align="center" prop="honorListName" :show-overflow-tooltip='true' width="150"/>
  80. <el-table-column label="荣誉榜单类型" align="center" prop="honorListType" :show-overflow-tooltip='true' width="150"/>
  81. <el-table-column label="来源" align="center" prop="source" :show-overflow-tooltip='true' width="150"/>
  82. <el-table-column label="协会/组织名称" align="center" prop="associationName" :show-overflow-tooltip='true' width="150"/>
  83. <el-table-column label="企业名称" align="center" prop="enterpriseName" :show-overflow-tooltip='true' width="150"/>
  84. <el-table-column label="发布年份" align="center" prop="releaseYear" :show-overflow-tooltip='true' width="150"/>
  85. </el-table>
  86. <div style="position: fixed;bottom: 20px;right: 10px;">
  87. <pagination
  88. v-show="total>0"
  89. :total="total"
  90. v-model:page="queryParams.pageNum"
  91. v-model:limit="queryParams.pageSize"
  92. @pagination="getList"
  93. />
  94. </div>
  95. <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
  96. <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  97. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  98. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  99. <el-icon class="el-icon--upload">
  100. <upload-filled/>
  101. </el-icon>
  102. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  103. <template #tip>
  104. <div class="el-upload__tip text-center">
  105. <span>仅允许导入xls、xlsx格式文件。</span>
  106. </div>
  107. </template>
  108. </el-upload>
  109. <template #footer>
  110. <div class="dialog-footer">
  111. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  112. <el-button @click="upload.open = false">取 消</el-button>
  113. </div>
  114. </template>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script setup name="Honor">
  119. import {
  120. listHonor,
  121. getHonor,
  122. delHonor,
  123. delHonorBatch
  124. } from "@/api/basicData/xcrAssociationHonor";
  125. import {reactive, ref, toRaw} from "vue";
  126. import {getToken} from "@/utils/auth";
  127. import {ElMessage} from "element-plus";
  128. import {likeQueryMethod} from "@/utils/likeQueryMethod";
  129. const {proxy} = getCurrentInstance();
  130. const xcrAssociationHonorList = ref([]);
  131. const open = ref(false);
  132. const loading = ref(true);
  133. const showSearch = ref(true);
  134. const ids = ref([]);
  135. const single = ref(true);
  136. const multiple = ref(true);
  137. const total = ref(0);
  138. const title = ref("");
  139. const upload = reactive({
  140. // 是否显示弹出层(用户导入)
  141. open: false,
  142. // 弹出层标题(用户导入)
  143. title: '',
  144. // 是否禁用上传
  145. isUploading: false,
  146. // 设置上传的请求头部
  147. headers: {Authorization: getToken()},
  148. // 上传的地址
  149. url: import.meta.env.VITE_APP_BASE_API + '/basicData/xcrAssociationHonor/importData'
  150. })
  151. const handleFileSuccess = (e) => {
  152. if (e.code == 200) {
  153. ElMessage({
  154. type: "success",
  155. message: e.msg
  156. })
  157. getList()
  158. proxy.$refs['uploadRef']?.clearFiles()
  159. } else {
  160. ElMessage({
  161. type: "error",
  162. message: e.msg
  163. })
  164. proxy.$refs['uploadRef']?.clearFiles()
  165. }
  166. }
  167. function submitFileForm() {
  168. proxy.$refs['uploadRef']?.submit();
  169. upload.open = false;
  170. }
  171. function handleImport() {
  172. upload.open = true
  173. }
  174. const data = reactive({
  175. form: {},
  176. queryParams: {
  177. pageNum: 1,
  178. pageSize: 20,
  179. honorListName: null,
  180. honorListType: null,
  181. source: null,
  182. associationName: null,
  183. enterpriseName: null,
  184. uniCode: '',
  185. releaseYear: null
  186. },
  187. rules: {
  188. honorListName: [
  189. {
  190. required: true, message: "荣誉榜单名称不能为空", trigger: "blur" }
  191. ],
  192. enterpriseName: [
  193. {
  194. required: true, message: "企业名称不能为空", trigger: "blur" }
  195. ],
  196. uniCode: [
  197. {
  198. required: true, message: "统一社会信用代码不能为空", trigger: "blur" }
  199. ],
  200. }
  201. });
  202. const {queryParams, form, rules} = toRefs(data);
  203. /** 查询协会等社会组织颁发的荣誉信息列表 */
  204. function getList() {
  205. loading.value = true;
  206. let toServerObj = likeQueryMethod('uni_code', queryParams.value.uniCode, queryParams.value.pageNum, queryParams.value.pageSize);
  207. listHonor(toServerObj).then(response => {
  208. xcrAssociationHonorList.value = response.records;
  209. total.value = response.total;
  210. loading.value = false;
  211. });
  212. }
  213. // 表单重置
  214. function reset() {
  215. form.value = {
  216. id: null,
  217. honorListName: null,
  218. honorListType: null,
  219. source: null,
  220. associationName: null,
  221. enterpriseName: null,
  222. uniCode: '',
  223. releaseYear: null
  224. };
  225. proxy.resetForm("xcrAssociationHonorRef");
  226. }
  227. /** 搜索按钮操作 */
  228. function handleQuery() {
  229. queryParams.value.pageNum = 1;
  230. getList();
  231. }
  232. /** 重置按钮操作 */
  233. function resetQuery() {
  234. proxy.resetForm("queryRef");
  235. handleQuery();
  236. }
  237. // 多选框选中数据
  238. function handleSelectionChange(selection) {
  239. ids.value = selection.map(item => item.id);
  240. single.value = selection.length != 1;
  241. multiple.value = !selection.length;
  242. }
  243. /** 删除按钮操作 */
  244. async function handleDelete(row) {
  245. const res = await delHonor();
  246. if(res.code == 200){
  247. ElMessage({
  248. type:'success',
  249. message:'删除成功'
  250. })
  251. getList();
  252. }
  253. }
  254. /** 批量删除*/
  255. const batchDelete = (row)=>{
  256. const idsToS = row.xhCodeId || ids.value;
  257. (proxy.$modal).confirm('是否确认删除这' + idsToS.length+'条的数据项?').then(function() {
  258. return delHonorBatch(toRaw(idsToS));
  259. }).then(() => {
  260. getList();
  261. proxy.$modal.msgSuccess("删除成功");
  262. }).catch(() => {});
  263. }
  264. /** 导出按钮操作 */
  265. function handleExport() {
  266. proxy.download('basicData/xcrAssociationHonor/export', {
  267. ...queryParams.value
  268. }, `协会等社会组织颁发的荣誉信息_${new Date().getTime()}.xlsx`)
  269. }
  270. const downloadTemplate = ()=>{
  271. proxy.download('basicData/xcrAssociationHonor/getUploadTemplate',{}, `协会等社会组织颁发的荣誉信息模板.xlsx`)
  272. }
  273. getList();
  274. </script>