index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="unitName" label-width="200">
  5. <el-input
  6. v-model="queryParams.unitName"
  7. placeholder="请输入单位名称"
  8. clearable
  9. @keyup.enter="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="统一社会信用代码" prop="unifiedSocialCreditCode" label-width="200">
  13. <el-input
  14. v-model="queryParams.unifiedSocialCreditCode"
  15. placeholder="请输入统一社会信用代码"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  22. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-popconfirm
  28. title="你确定清除所有数据?"
  29. confirm-button-text="是的"
  30. cancel-button-text="不是"
  31. :icon="InfoFilled"
  32. icon-color="#626AEF"
  33. @confirm="handleDelete"
  34. >
  35. <template #reference>
  36. <el-button
  37. type="danger"
  38. plain
  39. icon="Delete"
  40. v-hasPermi="['basicData:ggxyjl:jnlyxx:sfqj:remove']"
  41. >清除全表
  42. </el-button>
  43. </template>
  44. </el-popconfirm>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="danger"
  49. plain
  50. icon="Delete"
  51. @click="batchDelete"
  52. v-hasPermi="['basicData:ggxyjl:jnlyxx:sfqj:remove']"
  53. :disabled="ids.length === 0"
  54. >批量删除
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="warning"
  60. plain
  61. icon="Download"
  62. @click="handleExport"
  63. :disabled="!usageList.length"
  64. v-hasPermi="['basicData:ggxyjl:jnlyxx:sfqj:export']"
  65. >导出
  66. </el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button type="info" plain icon="Upload" @click="handleImport"
  70. v-hasPermi="['basicData:ggxyjl:jnlyxx:sfqj:import']">导入
  71. </el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button type="success" plain icon="Download" @click="downloadTemplate" v-hasPermi="['basicData:ggxyjl:jnlyxx:sfqj:download']">
  75. 下载导入模版
  76. </el-button>
  77. </el-col>
  78. </el-row>
  79. <el-table v-loading="loading" :data="usageList" height="650" @selection-change="handleSelectionChange">
  80. <el-table-column type="selection" width="55" align="center"/>
  81. <el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip='true'/>
  82. <el-table-column label="统一社会信用代码" align="center" prop="unifiedSocialCreditCode" width="200"/>
  83. <el-table-column label="年度" align="center" prop="annual" :show-overflow-tooltip='true'/>
  84. <el-table-column label="第一季度(吨)" align="center" prop="firstQuarterUsage" :show-overflow-tooltip='true'/>
  85. <el-table-column label="第二季度(吨)" align="center" prop="secondQuarterUsage" :show-overflow-tooltip='true'/>
  86. <el-table-column label="第三季度(吨)" align="center" prop="thirdQuarterUsage" :show-overflow-tooltip='true'/>
  87. <el-table-column label="第四季度(吨)" align="center" prop="fourthQuarterUsage" :show-overflow-tooltip='true'/>
  88. <el-table-column label="合计(吨)" align="center" prop="total" :show-overflow-tooltip='true'/>
  89. <el-table-column label="当前是否欠缴水费" align="center" prop="isCurrentlyInArrears" :show-overflow-tooltip='true'/>
  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. <!-- 添加或修改季度用水明细对话框 -->
  122. </div>
  123. </template>
  124. <script setup name="Usage">
  125. import {
  126. listUsage,
  127. getUsage,
  128. delUsage,
  129. delUsageBatch
  130. } from "@/api/basicData/usage";
  131. import {reactive, ref, toRaw} from "vue";
  132. import {getToken} from "@/utils/auth";
  133. import {ElMessage} from "element-plus";
  134. import {likeQueryMethod} from "@/utils/likeQueryMethod";
  135. const {proxy} = getCurrentInstance();
  136. const usageList = ref([]);
  137. const open = ref(false);
  138. const loading = ref(true);
  139. const showSearch = ref(true);
  140. const ids = ref([]);
  141. const single = ref(true);
  142. const multiple = ref(true);
  143. const total = ref(0);
  144. const title = ref("");
  145. const upload = reactive({
  146. // 是否显示弹出层(用户导入)
  147. open: false,
  148. // 弹出层标题(用户导入)
  149. title: '',
  150. // 是否禁用上传
  151. isUploading: false,
  152. // 设置上传的请求头部
  153. headers: {Authorization: getToken()},
  154. // 上传的地址
  155. url: import.meta.env.VITE_APP_BASE_API + '/crmQuarterlyWaterUsage/importData'
  156. })
  157. const handleFileSuccess = (e) => {
  158. if (e.code == 200) {
  159. ElMessage({
  160. type: "success",
  161. message: e.msg
  162. })
  163. getList()
  164. proxy.$refs['uploadRef']?.clearFiles()
  165. } else {
  166. ElMessage({
  167. type: "error",
  168. message: e.msg
  169. })
  170. proxy.$refs['uploadRef']?.clearFiles()
  171. }
  172. }
  173. function submitFileForm() {
  174. proxy.$refs['uploadRef']?.submit();
  175. upload.open = false;
  176. }
  177. function handleImport() {
  178. upload.open = true
  179. }
  180. const data = reactive({
  181. form: {},
  182. queryParams: {
  183. pageNum: 1,
  184. pageSize: 20,
  185. unitName: null,
  186. unifiedSocialCreditCode: '',
  187. firstQuarterUsage: null,
  188. secondQuarterUsage: null,
  189. thirdQuarterUsage: null,
  190. fourthQuarterUsage: null,
  191. total: null,
  192. annual: null,
  193. isCurrentlyInArrears: null
  194. },
  195. rules: {
  196. unitName: [
  197. {
  198. required: true, message: "单位名称不能为空", trigger: "blur"
  199. }
  200. ],
  201. unifiedSocialCreditCode: [
  202. {
  203. required: true, message: "统一社会信用代码不能为空", trigger: "blur"
  204. }
  205. ],
  206. }
  207. });
  208. const {queryParams, form, rules} = toRefs(data);
  209. /** 查询季度用水明细列表 */
  210. function getList() {
  211. loading.value = true;
  212. let toServerObj = likeQueryMethod('unified_social_credit_code', queryParams.value.unifiedSocialCreditCode, queryParams.value.pageNum, queryParams.value.pageSize,'unit_name',queryParams.value.unitName);
  213. listUsage(toServerObj).then(response => {
  214. usageList.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. unitName: null,
  224. unifiedSocialCreditCode: '',
  225. firstQuarterUsage: null,
  226. secondQuarterUsage: null,
  227. thirdQuarterUsage: null,
  228. fourthQuarterUsage: null,
  229. total: null,
  230. annual: null,
  231. isCurrentlyInArrears: null
  232. };
  233. proxy.resetForm("usageRef");
  234. }
  235. /** 搜索按钮操作 */
  236. function handleQuery() {
  237. queryParams.value.pageNum = 1;
  238. getList();
  239. }
  240. /** 重置按钮操作 */
  241. function resetQuery() {
  242. proxy.resetForm("queryRef");
  243. handleQuery();
  244. }
  245. // 多选框选中数据
  246. function handleSelectionChange(selection) {
  247. ids.value = selection.map(item => item.id);
  248. single.value = selection.length != 1;
  249. multiple.value = !selection.length;
  250. }
  251. /** 删除按钮操作 */
  252. async function handleDelete(row) {
  253. const res = await delUsage();
  254. if (res.code == 200) {
  255. ElMessage({
  256. type: 'success',
  257. message: '删除成功'
  258. })
  259. getList();
  260. }
  261. }
  262. /** 批量删除*/
  263. const batchDelete = (row) => {
  264. const idsToS = row.id || ids.value;
  265. (proxy.$modal).confirm('是否确认删除这' + idsToS.length + '条的数据项?').then(function () {
  266. return delUsageBatch(toRaw(idsToS));
  267. }).then(() => {
  268. getList();
  269. proxy.$modal.msgSuccess("删除成功");
  270. }).catch(() => {
  271. });
  272. }
  273. /** 导出按钮操作 */
  274. function handleExport() {
  275. proxy.download('crmQuarterlyWaterUsage/exportData', {
  276. ...queryParams.value
  277. }, `季度用水明细_${new Date().getTime()}.xlsx`)
  278. }
  279. const downloadTemplate = () => {
  280. proxy.download('crmQuarterlyWaterUsage/getUploadTemplate', {}, `季度用水明细模板.xlsx`)
  281. }
  282. getList();
  283. </script>