index2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="gasReport">
  4. <customHeader>瓦斯巡检地点管理</customHeader>
  5. <div class="report-container">
  6. <div class="search-area">
  7. <a-row>
  8. <a-col :span="4">
  9. <div class="area-item">
  10. <div class="item-text">地点:</div>
  11. <a-input style="width: 240px" v-model:value="searchParams" placeholder="请输入地点" />
  12. </div>
  13. </a-col>
  14. <a-col :span="20">
  15. <a-button type="primary" preIcon="ant-design:search-outlined" class="" @click="getSearchCardId">查询</a-button>
  16. <a-button preIcon="ant-design:sync-outlined" class="ml-10px" @click="getReset">重置</a-button>
  17. <a-button type="primary" preIcon="ant-design:import-outlined" class="ml-10px" @click="getupload">导入</a-button>
  18. <a-button type="primary" preIcon="ant-design:download-outlined" class="ml-10px" @click="getdownload">导出</a-button>
  19. <a-button type="primary" preIcon="ant-design:plus-outlined" class="ml-10px" @click="getTjAddress">新增瓦斯巡检地址</a-button>
  20. </a-col>
  21. </a-row>
  22. </div>
  23. <a-table
  24. :key="keyActive"
  25. :columns="columns2"
  26. size="small"
  27. :data-source="tableData"
  28. :scroll="{ y: 500 }"
  29. class="tableW"
  30. :pagination="pagination"
  31. @change="pageChange"
  32. >
  33. <template #action="{ record }">
  34. <a class="table-action-link" @click="handlerEdit(record)">编辑</a>
  35. <a-popconfirm title="删除内容无法恢复,是否删除" ok-text="确定" cancel-text="取消" @confirm="handleDelCardInfo(record)">
  36. <a class="table-action-link">删除</a>
  37. </a-popconfirm>
  38. </template>
  39. <template #bodyCell="{ column, text }">
  40. <template v-if="column.dataIndex == 'isSensor'">
  41. <div v-if="text == '1'">
  42. <div class="table-text text-y">是</div>
  43. </div>
  44. <div v-else>
  45. <div class="table-text text-n">否</div>
  46. </div>
  47. </template>
  48. <template v-if="column.dataIndex == 'checkState'">
  49. <div v-if="text == '1'">
  50. <div class="table-text text-y">已检</div>
  51. </div>
  52. <div v-else>
  53. <div class="table-text text-n">未检</div>
  54. </div>
  55. </template>
  56. </template>
  57. </a-table>
  58. <!-- 任务管理弹窗 -->
  59. <a-modal v-model:visible="visibleTask" width="850px" :footer="null" :title="titleTask" centered destroyOnClose>
  60. <inspectTask @handleTaskSubmit="handleTaskSubmit" @handleTaskCancel="handleTaskCancel" />
  61. </a-modal>
  62. <!-- 编辑弹窗 -->
  63. <a-modal v-model:visible="visibleEdit" width="650px" :footer="null" :title="titleEdit" centered destroyOnClose>
  64. <inspectEdit :inspectEditData="inspectEditData" @confirmEdit="confirmEdit" @cancelEdit="cancelEdit" />
  65. </a-modal>
  66. <!-- 导入弹窗 -->
  67. <a-modal v-model:visible="visibleUploadorDown" width="450px" :footer="null" :title="titleUploadorDown" centered destroyOnClose>
  68. <uploadOrdown :modalType="modalType" @handlerComfirm="handlerComfirm" @handlerCancel="handlerCancel" />
  69. </a-modal>
  70. <!-- 新增瓦斯巡检地点弹窗 -->
  71. <a-modal v-model:visible="visibleAddress" width="450px" :footer="null" :title="titleAddress" centered destroyOnClose>
  72. <addressAdd @confirmAddress="confirmAddress" @cancelAddress="cancelAddress" />
  73. </a-modal>
  74. </div>
  75. </div>
  76. </template>
  77. <script setup lang="ts">
  78. import { ref, onMounted, reactive } from 'vue';
  79. import customHeader from '/@/components/vent/customHeader.vue';
  80. import inspectTask from './components/inspectTask.vue';
  81. import inspectEdit from './components/inspectEdit2.vue';
  82. import uploadOrdown from './components/uploadOrdown.vue';
  83. import addressAdd from './components/addressAdd2.vue';
  84. import { message } from 'ant-design-vue';
  85. import { columns2, pagination } from './gasInspectNonfc.data';
  86. import { list, importByExcel, exportGasByExcel, moveOrderNum, edit, taskSubmit, clearCardInfo, addGasReportAddress } from './gasInspectNonfc.api';
  87. let keyActive = ref(0);
  88. let searchParams = ref('');
  89. let tableData = ref<any[]>([]); //巡检列表
  90. let visibleTask = ref(false); //控制任务管理弹窗的显示与隐藏
  91. let titleTask = ref('');
  92. let visibleEdit = ref(false); //控制编辑弹窗的显示与隐藏
  93. let titleEdit = ref(''); //编辑弹窗标题
  94. let inspectEditData = reactive({}); //编辑弹窗数据
  95. let visibleUploadorDown = ref(false); //控制导入/导出弹窗的显示与隐藏
  96. let titleUploadorDown = ref('');
  97. let modalType = ref(''); //判断当前是导入/导出弹窗
  98. let visibleAddress = ref(false); //控制巡检地址新增弹窗的显示与隐藏
  99. let titleAddress = ref(''); //区队巡检地址新增弹窗标题
  100. //打开任务管理弹窗
  101. // let handlerTask = () => {
  102. // visibleTask.value = true;
  103. // titleTask.value = '瓦斯巡检任务管理';
  104. // };
  105. //任务管理下发
  106. async function handleTaskSubmit(param) {
  107. let res = await taskSubmit({ ...param });
  108. if (res) {
  109. visibleTask.value = false;
  110. queryByIdList();
  111. }
  112. }
  113. //任务管理弹窗关闭
  114. let handleTaskCancel = () => {
  115. visibleTask.value = false;
  116. };
  117. //打开编辑弹窗
  118. let handlerEdit = (record) => {
  119. visibleEdit.value = true;
  120. titleEdit.value = '瓦斯巡检点编辑';
  121. inspectEditData = Object.assign({}, record);
  122. };
  123. //编辑提交
  124. async function confirmEdit(param) {
  125. let res = await edit({ ...param });
  126. if (res) {
  127. queryByIdList();
  128. visibleEdit.value = false;
  129. }
  130. }
  131. //编辑取消
  132. let cancelEdit = () => {
  133. visibleEdit.value = false;
  134. };
  135. //删除巡检卡信息
  136. async function handleDelCardInfo(record) {
  137. let res = await clearCardInfo({ id: record.id });
  138. if (res) {
  139. queryByIdList();
  140. }
  141. }
  142. //通过地点查询
  143. async function queryByIdList() {
  144. let res = await list({ strinstallpos: searchParams.value, pageNo: pagination.current, pageSize: pagination.pageSize });
  145. keyActive.value = new Date().getTime();
  146. tableData.value = res.records.map((el: any) => {
  147. return {
  148. morning: el.insType,
  149. afterNoon: el.insType,
  150. evening: el.insType,
  151. ...el,
  152. };
  153. });
  154. pagination.total = res.total;
  155. }
  156. //查询
  157. let getSearchCardId = () => {
  158. pagination.current = 1;
  159. queryByIdList();
  160. };
  161. //重置
  162. let getReset = () => {
  163. pagination.current = 1;
  164. searchParams.value = '';
  165. queryByIdList();
  166. };
  167. //分页切换
  168. let pageChange = (val) => {
  169. pagination.current = val.current;
  170. pagination.pageSize = val.pageSize;
  171. queryByIdList();
  172. };
  173. //导入
  174. let getupload = () => {
  175. modalType.value = 'upload';
  176. visibleUploadorDown.value = true;
  177. titleUploadorDown.value = '导入';
  178. };
  179. //确定导入
  180. async function handlerComfirm(param) {
  181. if (modalType.value == 'upload') {
  182. let res = await importByExcel(param);
  183. if (res.code == 200) {
  184. visibleUploadorDown.value = false;
  185. message.success('导入成功');
  186. queryByIdList();
  187. }
  188. } else {
  189. let res = await exportGasByExcel({ insType: param.insType });
  190. console.log(res, '导出数据');
  191. if (res) {
  192. let filename = `${new Date().getTime()}.xlsx`;
  193. downFilePublic(res, filename);
  194. message.success('导出成功');
  195. }
  196. }
  197. }
  198. //导出
  199. let getdownload = () => {
  200. modalType.value = 'download';
  201. visibleUploadorDown.value = true;
  202. titleUploadorDown.value = '导出';
  203. };
  204. //确定导出
  205. async function handlerCancel() {
  206. modalType.value = '';
  207. }
  208. // 下载公用方法
  209. function downFilePublic(content, fileName) {
  210. const blob = new Blob([content], { type: 'application/xlsx;charset=UTF-8' }); // 构造一个blob对象来处理数据
  211. // 对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
  212. // IE10以上支持blob但是依然不支持download
  213. if ('download' in document.createElement('a')) {
  214. // 支持a标签download的浏览器
  215. const link = document.createElement('a'); // 创建a标签
  216. link.download = fileName; // a标签添加属性
  217. link.style.display = 'none';
  218. link.href = URL.createObjectURL(blob);
  219. document.body.appendChild(link);
  220. link.click(); // 执行下载
  221. URL.revokeObjectURL(link.href); // 释放url
  222. document.body.removeChild(link); // 释放标签
  223. } else {
  224. // 其他浏览器
  225. // navigator.msSaveBlob(blob, fileName);
  226. }
  227. }
  228. //列表上移
  229. async function moveUp(param) {
  230. let res = await moveOrderNum({ id: param.id, moveType: 'upp' });
  231. console.log(res, '向上移动');
  232. if (res) {
  233. queryByIdList();
  234. }
  235. }
  236. //列表下移
  237. async function moveDown(param) {
  238. let res = await moveOrderNum({ id: param.id, moveType: 'bel' });
  239. console.log(res, '向下移动');
  240. if (res) {
  241. queryByIdList();
  242. }
  243. }
  244. //巡检次数筛选
  245. let handlerFilter = (param) => {
  246. let data = param.key;
  247. switch (data) {
  248. case '1':
  249. pagination.current = 1;
  250. tableData.value = tableData.value.filter((v) => v.insType == '1');
  251. break;
  252. case '2':
  253. pagination.current = 2;
  254. tableData.value = tableData.value.filter((v) => v.insType == '2');
  255. break;
  256. }
  257. };
  258. //新增瓦斯巡检地点
  259. let getTjAddress = () => {
  260. visibleAddress.value = true;
  261. titleAddress.value = '新增瓦斯巡检地址';
  262. };
  263. //确定新增
  264. async function confirmAddress(param) {
  265. let res = await addGasReportAddress(param);
  266. console.log(res, '新增瓦斯巡检地点');
  267. if (res) {
  268. visibleAddress.value = false;
  269. queryByIdList();
  270. }
  271. }
  272. //取消新增
  273. let cancelAddress = () => {
  274. visibleAddress.value = false;
  275. };
  276. onMounted(() => {
  277. queryByIdList();
  278. });
  279. </script>
  280. <style lang="less" scoped>
  281. .gasReport {
  282. width: 100%;
  283. height: 100%;
  284. padding: 80px 10px 15px 10px;
  285. box-sizing: border-box;
  286. position: relative;
  287. .search-area {
  288. margin: 20px 0px;
  289. .area-item {
  290. display: flex;
  291. align-items: center;
  292. .item-text {
  293. color: #fff;
  294. }
  295. }
  296. }
  297. .table-text {
  298. margin-bottom: 5px;
  299. }
  300. .text-y {
  301. color: #0be716;
  302. }
  303. .text-n {
  304. color: #ff0000;
  305. }
  306. .zxm-picker,
  307. .zxm-input {
  308. border: 1px solid #3ad8ff77 !important;
  309. background-color: #ffffff00 !important;
  310. color: #fff !important;
  311. }
  312. }
  313. :deep(.zxm-table-thead > tr > th:last-child) {
  314. border-right: 1px solid #91e9fe !important;
  315. }
  316. :deep(.zxm-picker-input > input) {
  317. color: #fff;
  318. }
  319. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  320. border: 1px solid #3ad8ff77 !important;
  321. background-color: #ffffff00 !important;
  322. }
  323. :deep(.zxm-select-selection-item) {
  324. color: #fff !important;
  325. }
  326. </style>