duChaQuYuList.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div
  3. style="height:100%;max-height:100%;overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;"
  4. >
  5. <div
  6. class="box-card"
  7. style="background-color: #ECF8FF; height: 40px; font-size: small; line-height: 30px; display: flex; justify-content: space-between; align-items: center;"
  8. >
  9. <div style="display:flex;" class="checkbox_left">
  10. <a-checkbox :checked="checked" @change="onChecked">本级</a-checkbox>
  11. <a-input-search
  12. v-model="input5"
  13. placeholder="请输入区域名称"
  14. enter-button
  15. @search="searchDcryResult"
  16. allow-clear
  17. style="width: 200px; margin-left: 30px;"
  18. />
  19. </div>
  20. <a-button
  21. v-if="dczId.length == 12"
  22. @click="editHandler"
  23. type="primary"
  24. icon="edit"
  25. size="small"
  26. ghost
  27. style="float: right; margin-right: 10px; height: 30px;"
  28. >添加区域</a-button
  29. >
  30. </div>
  31. <a-table
  32. :columns="columns"
  33. :data-source="tableData"
  34. @change="handleCurrentChange"
  35. :loading="loading"
  36. rowKey="index"
  37. :pagination="{
  38. total,
  39. defaultPageSize: pageSize,
  40. showTotal: (total) => `共${total}条`,
  41. }"
  42. style="width: 100%;"
  43. :style="{ height: tableHeight + 'px' }"
  44. >
  45. <template #bodyCell="{ column, record }">
  46. <template v-if="column.dataIndex === 'action' && ownPriv('manage')">
  47. <a @click="showConfirmDialog(record)">删除</a>
  48. </template>
  49. </template>
  50. </a-table>
  51. <a-modal
  52. v-model:open="confirmDialogVisible"
  53. title="提示"
  54. @ok="deleteHandler"
  55. @cancel="confirmDialogVisible = false"
  56. >
  57. <div>
  58. <span>是否删除该区域下的所有督查对象</span>
  59. <a-radio-group v-model:value="isDeleteObj">
  60. <a-radio :value="1">是</a-radio>
  61. <a-radio :value="2">否</a-radio>
  62. </a-radio-group>
  63. </div>
  64. </a-modal>
  65. </div>
  66. </template>
  67. <script>
  68. import { Modal } from 'ant-design-vue';
  69. import {
  70. deleteDcqy,
  71. getDcqyList,
  72. getDcqyListAll,
  73. } from '../../api/duChaPlan.js';
  74. export default {
  75. props: ['objType', 'dczId', 'dczName'],
  76. computed: {
  77. userInAllNode: () => {
  78. // 当前登录用户所在的所有组信息
  79. return JSON.parse(localStorage.getItem('allNode'))
  80. ? JSON.parse(localStorage.getItem('allNode'))
  81. : [];
  82. },
  83. isAdmin: () =>
  84. localStorage.getItem('isAdmin') ? localStorage.getItem('isAdmin') : '',
  85. },
  86. data() {
  87. return {
  88. input5: '',
  89. checked: false,
  90. loading: true,
  91. pageIndex: 1,
  92. pageSize: 10,
  93. total: 0,
  94. showResultCount: 0,
  95. showEdit: true,
  96. tableData: [],
  97. currentShowList: [],
  98. tableHeight: window.innerHeight - 280,
  99. isAll: '0',
  100. confirmDialogVisible: false, // 确定删除区域弹窗是否显示
  101. isDeleteObj: 2, // 是否删除区域下的所有督查对象 1 是 2 否
  102. itemInfo: null, // 当前选中区域的额信息
  103. columns: [
  104. {
  105. title: '序号',
  106. dataIndex: 'index',
  107. align: 'center',
  108. ellipsis: true,
  109. customCell: () => {
  110. return {
  111. style: {
  112. 'min-width': '70px',
  113. },
  114. };
  115. },
  116. customHeaderCell: () => {
  117. return {
  118. style: {
  119. 'min-width': '70px',
  120. },
  121. };
  122. },
  123. },
  124. {
  125. title: '名称',
  126. dataIndex: 'adName',
  127. align: 'center',
  128. ellipsis: true,
  129. customCell: () => {
  130. return {
  131. style: {
  132. 'min-width': '80px',
  133. },
  134. };
  135. },
  136. customHeaderCell: () => {
  137. return {
  138. style: {
  139. 'min-width': '80px',
  140. },
  141. };
  142. },
  143. },
  144. {
  145. title: '编码',
  146. dataIndex: 'adCode',
  147. align: 'center',
  148. ellipsis: true,
  149. customCell: () => {
  150. return {
  151. style: {
  152. 'min-width': '100px',
  153. },
  154. };
  155. },
  156. customHeaderCell: () => {
  157. return {
  158. style: {
  159. 'min-width': '100px',
  160. },
  161. };
  162. },
  163. },
  164. {
  165. title: '所在分组',
  166. dataIndex: 'pnm',
  167. align: 'center',
  168. ellipsis: true,
  169. customCell: () => {
  170. return {
  171. style: {
  172. 'min-width': '80px',
  173. },
  174. };
  175. },
  176. customHeaderCell: () => {
  177. return {
  178. style: {
  179. 'min-width': '80px',
  180. },
  181. };
  182. },
  183. },
  184. {
  185. title: '操作',
  186. dataIndex: 'action',
  187. align: 'center',
  188. fixed: 'right',
  189. customCell: () => {
  190. return {
  191. style: {
  192. 'min-width': '140px',
  193. },
  194. };
  195. },
  196. customHeaderCell: () => {
  197. return {
  198. style: {
  199. 'min-width': '140px',
  200. },
  201. };
  202. },
  203. },
  204. ],
  205. };
  206. },
  207. mounted() {
  208. this.getDcqyResult(); // 获取督查人员列表
  209. },
  210. methods: {
  211. getDcqyResult() {
  212. if (!this.dczId) {
  213. this.loading = false;
  214. return;
  215. }
  216. this.loading = true;
  217. if (this.isAll == '1') {
  218. getDcqyList(
  219. this.dczId,
  220. this.pageSize,
  221. this.pageIndex,
  222. this.input5,
  223. ).then((response) => {
  224. this.tableData = response.data.list;
  225. this.total = response.data.total;
  226. this.loading = false;
  227. this.tableData.forEach((element, index) => {
  228. element['index'] = this.pageSize * (this.pageIndex - 1) + index + 1;
  229. });
  230. });
  231. } else {
  232. getDcqyListAll(
  233. this.dczId,
  234. this.pageSize,
  235. this.pageIndex,
  236. this.input5,
  237. ).then((response) => {
  238. this.tableData = response.data.list;
  239. this.total = response.data.total;
  240. this.loading = false;
  241. this.tableData.forEach((element, index) => {
  242. element['index'] = this.pageSize * (this.pageIndex - 1) + index + 1;
  243. });
  244. });
  245. }
  246. },
  247. onChecked(e) {
  248. this.checked = e.target.checked;
  249. },
  250. searchDcryResult(val) {
  251. this.input5 = val;
  252. this.pageIndex = 1;
  253. this.getDcqyResult();
  254. },
  255. editHandler(item) {
  256. this.$emit('showEditDialog', item);
  257. },
  258. handleCurrentChange(item) {
  259. this.pageIndex = item.current;
  260. this.getDcqyResult();
  261. },
  262. showConfirmDialog(row) {
  263. this.confirmDialogVisible = true;
  264. this.itemInfo = row;
  265. },
  266. deleteHandler() {
  267. Modal.confirm({
  268. title: '提示',
  269. content: '是否确认删除?',
  270. okType: 'warning',
  271. onOk: () => {
  272. deleteDcqy(this.itemInfo.areaId, this.isDeleteObj).then(
  273. (response) => {
  274. this.getDcqyResult();
  275. this.$message.success('删除成功');
  276. this.confirmDialogVisible = false;
  277. },
  278. );
  279. return Promise.resolve();
  280. },
  281. onCancel: () => {
  282. this.$message.info('已取消删除');
  283. },
  284. });
  285. },
  286. },
  287. watch: {
  288. dczId: {
  289. immediate: true,
  290. handler(n, o) {
  291. console.log('[duChaQuYuList] dczId变化:', n);
  292. this.getDcqyResult(n);
  293. },
  294. },
  295. checked(n, o) {
  296. if (n == true) {
  297. this.isAll = '1';
  298. } else {
  299. this.isAll = '0';
  300. }
  301. this.pageIndex = 1;
  302. this.getDcqyResult();
  303. },
  304. },
  305. };
  306. </script>
  307. <style lang="less" scoped>
  308. .checkbox_left {
  309. margin-left: 20px;
  310. }
  311. :deep(.ant-checkbox-wrapper ) {
  312. white-space: nowrap;
  313. }
  314. :deep(.ant-table-pagination ) {
  315. float: left;
  316. }
  317. /deep/ .ant-table-thead > tr > th,
  318. /deep/ .ant-table-tbody > tr > td {
  319. padding: 0;
  320. height: 50px;
  321. }
  322. </style>