index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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="!xcrBrandHonorsList.length"
  25. v-hasPermi="['basicData:xcrBrandHonors: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:xcrBrandHonors: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:xcrBrandHonors: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:honors: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="xcrBrandHonorsList" 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="enterpriseName" :show-overflow-tooltip='true' width="150"/>
  80. <el-table-column label="品牌荣誉名称" align="center" prop="honorName" :show-overflow-tooltip='true' width="150"/>
  81. <el-table-column label="知名品牌" align="center" prop="wellKnownBrand" :show-overflow-tooltip='true' width="150"/>
  82. <el-table-column label="驰名商标" align="center" prop="famousTrademark" :show-overflow-tooltip='true' width="150"/>
  83. <el-table-column label="荣誉颁发部门" align="center" prop="issuingDepartment" :show-overflow-tooltip='true' width="150"/>
  84. <el-table-column label="取得荣誉日期" align="center" prop="awardDate" width="180">
  85. <template #default="scope">
  86. <span>{{ parseTime(scope.row.awardDate, '{y}-{m}-{d}') }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="荣誉证明文件号" align="center" prop="honorCertificateNumber" :show-overflow-tooltip='true' width="150"/>
  90. </el-table>
  91. <div style="position: fixed;bottom: 20px;right: 10px;">
  92. <pagination
  93. v-show="total>0"
  94. :total="total"
  95. v-model:page="queryParams.pageNum"
  96. v-model:limit="queryParams.pageSize"
  97. @pagination="getList"
  98. />
  99. </div>
  100. <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
  101. <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  102. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  103. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  104. <el-icon class="el-icon--upload">
  105. <upload-filled/>
  106. </el-icon>
  107. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  108. <template #tip>
  109. <div class="el-upload__tip text-center">
  110. <span>仅允许导入xls、xlsx格式文件。</span>
  111. </div>
  112. </template>
  113. </el-upload>
  114. <template #footer>
  115. <div class="dialog-footer">
  116. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  117. <el-button @click="upload.open = false">取 消</el-button>
  118. </div>
  119. </template>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script setup name="Honors">
  124. import {
  125. listHonors,
  126. getHonors,
  127. delHonors,
  128. delHonorsBatch
  129. } from "@/api/basicData/xcrBrandHonors";
  130. import {reactive, ref, toRaw} from "vue";
  131. import {getToken} from "@/utils/auth";
  132. import {ElMessage} from "element-plus";
  133. import {likeQueryMethod} from "@/utils/likeQueryMethod";
  134. const {proxy} = getCurrentInstance();
  135. const xcrBrandHonorsList = ref([]);
  136. const open = ref(false);
  137. const loading = ref(true);
  138. const showSearch = ref(true);
  139. const ids = ref([]);
  140. const single = ref(true);
  141. const multiple = ref(true);
  142. const total = ref(0);
  143. const title = ref("");
  144. const upload = reactive({
  145. // 是否显示弹出层(用户导入)
  146. open: false,
  147. // 弹出层标题(用户导入)
  148. title: '',
  149. // 是否禁用上传
  150. isUploading: false,
  151. // 设置上传的请求头部
  152. headers: {Authorization: getToken()},
  153. // 上传的地址
  154. url: import.meta.env.VITE_APP_BASE_API + '/basicData/xcrBrandHonors/importData'
  155. })
  156. const handleFileSuccess = (e) => {
  157. if (e.code == 200) {
  158. ElMessage({
  159. type: "success",
  160. message: e.msg
  161. })
  162. getList()
  163. proxy.$refs['uploadRef']?.clearFiles()
  164. } else {
  165. ElMessage({
  166. type: "error",
  167. message: e.msg
  168. })
  169. proxy.$refs['uploadRef']?.clearFiles()
  170. }
  171. }
  172. function submitFileForm() {
  173. proxy.$refs['uploadRef']?.submit();
  174. upload.open = false;
  175. }
  176. function handleImport() {
  177. upload.open = true
  178. }
  179. const data = reactive({
  180. form: {},
  181. queryParams: {
  182. pageNum: 1,
  183. pageSize: 20,
  184. enterpriseName: null,
  185. uniCode: '',
  186. honorName: null,
  187. wellKnownBrand: null,
  188. famousTrademark: null,
  189. issuingDepartment: null,
  190. awardDate: null,
  191. honorCertificateNumber: null
  192. },
  193. rules: {
  194. enterpriseName: [
  195. {
  196. required: true, message: "企业名称不能为空", trigger: "blur" }
  197. ],
  198. uniCode: [
  199. {
  200. required: true, message: "统一社会信用代码不能为空", trigger: "blur" }
  201. ],
  202. honorName: [
  203. {
  204. required: true, message: "品牌荣誉名称不能为空", trigger: "blur" }
  205. ],
  206. }
  207. });
  208. const {queryParams, form, rules} = toRefs(data);
  209. /** 查询品牌荣誉信息列表 */
  210. function getList() {
  211. loading.value = true;
  212. let toServerObj = likeQueryMethod('uni_code', queryParams.value.uniCode, queryParams.value.pageNum, queryParams.value.pageSize);
  213. listHonors(toServerObj).then(response => {
  214. xcrBrandHonorsList.value = response.records;
  215. total.value = response.total;
  216. loading.value = false;
  217. });
  218. }
  219. // 表单重置
  220. function reset() {
  221. form.value = {
  222. id: null,
  223. enterpriseName: null,
  224. uniCode: '',
  225. honorName: null,
  226. wellKnownBrand: null,
  227. famousTrademark: null,
  228. issuingDepartment: null,
  229. awardDate: null,
  230. honorCertificateNumber: null
  231. };
  232. proxy.resetForm("xcrBrandHonorsRef");
  233. }
  234. /** 搜索按钮操作 */
  235. function handleQuery() {
  236. queryParams.value.pageNum = 1;
  237. getList();
  238. }
  239. /** 重置按钮操作 */
  240. function resetQuery() {
  241. proxy.resetForm("queryRef");
  242. handleQuery();
  243. }
  244. // 多选框选中数据
  245. function handleSelectionChange(selection) {
  246. ids.value = selection.map(item => item.id);
  247. single.value = selection.length != 1;
  248. multiple.value = !selection.length;
  249. }
  250. /** 删除按钮操作 */
  251. async function handleDelete(row) {
  252. const res = await delHonors();
  253. if(res.code == 200){
  254. ElMessage({
  255. type:'success',
  256. message:'删除成功'
  257. })
  258. getList();
  259. }
  260. }
  261. /** 批量删除*/
  262. const batchDelete = (row)=>{
  263. const idsToS = row.xhCodeId || ids.value;
  264. (proxy.$modal).confirm('是否确认删除这' + idsToS.length+'条的数据项?').then(function() {
  265. return delHonorsBatch(toRaw(idsToS));
  266. }).then(() => {
  267. getList();
  268. proxy.$modal.msgSuccess("删除成功");
  269. }).catch(() => {});
  270. }
  271. /** 导出按钮操作 */
  272. function handleExport() {
  273. proxy.download('basicData/xcrBrandHonors/export', {
  274. ...queryParams.value
  275. }, `品牌荣誉信息_${new Date().getTime()}.xlsx`)
  276. }
  277. const downloadTemplate = ()=>{
  278. proxy.download('basicData/xcrBrandHonors/getUploadTemplate',{}, `品牌荣誉信息模板.xlsx`)
  279. }
  280. getList();
  281. </script>