index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <el-dropdown trigger="click">
  6. <el-button type="primary" size="small">
  7. 其它<el-icon class="el-icon--right"><arrow-down /></el-icon>
  8. </el-button>
  9. <template #dropdown>
  10. <el-dropdown-menu>
  11. <el-dropdown-item icon="Download" @click="handleExport" v-hasPermi="['business:salaryZero:export']">
  12. 导出</el-dropdown-item>
  13. <el-dropdown-item icon="Upload" @click="handleImport"
  14. v-hasPermi="['business:salaryZero:import']">导入</el-dropdown-item>
  15. </el-dropdown-menu>
  16. </template>
  17. </el-dropdown>
  18. </div>
  19. <!-- 搜索区 -->
  20. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  21. label-width="78px">
  22. <el-form-item label="客户名称:" prop="companyName">
  23. <el-input v-model="queryParams.companyName" placeholder="请输入客户名称" clearable style="width: 150px"
  24. @keyup.enter="handleQuery" />
  25. </el-form-item>
  26. <el-form-item label="月份:">
  27. <el-select v-model.trim="queryParams.month" size="small" placeholder="月份" style="width: 130px"
  28. @change="handleQuery" :clearable="false">
  29. <el-option v-for="item in selectMonths" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="状态:">
  33. <el-select v-model.trim="queryParams.status" prop="status" size="small" type="text" placeholder="状态"
  34. :clearable="true" style="width: 130px" @clear="clearStatus">
  35. <el-option v-for="item in selectStatus" :key="item.value" :label="item.label" :value="item.value" />
  36. </el-select>
  37. </el-form-item>
  38. <!-- <el-form-item v-if="tenant.versionId !== '4'" label="是否自己负责:" v-hasPermi="['business:wage:person']">
  39. <el-switch v-model="oneself" @change="handleOneself" />
  40. </el-form-item> -->
  41. <el-form-item>
  42. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  43. <el-button icon="operation" @click="moreSearch = true">更多</el-button>
  44. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" v-if="flag">
  48. <el-tab-pane label="全部" name="first">
  49. </el-tab-pane>
  50. <el-tab-pane label="我的" name="second">
  51. </el-tab-pane>
  52. </el-tabs>
  53. <!-- 列表区 -->
  54. <el-table v-loading="loading" :data="list" size="small" border height="100%"
  55. @selection-change="handleSelectionChange" >
  56. <el-table-column type="selection" width="55" align="center" />
  57. <el-table-column label="客户名称" align="center" prop="companyName" min-width="250" />
  58. <el-table-column label="来源" align="center" prop="fromCompanyName" min-width="100" />
  59. <el-table-column label="纳税性质" align="center" min-width="130" prop="taxType" />
  60. <el-table-column label="税号" align="center" prop="socialCreditCode" min-width="200" />
  61. <el-table-column label="当前期间" min-width="90" align="center">
  62. <template #default="scope">
  63. {{ moment().subtract(1, "month").format("YYYY年MM月") }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column align="center">
  67. <template #header>
  68. <div style="
  69. display: flex;
  70. flex-direction: row;
  71. justify-content: space-between;
  72. ">
  73. <div style="display: flex; flex-direction: row">
  74. <el-button link type="primary" size="small" icon="ArrowLeft" @click="prevYear" />
  75. <el-link style="margin: 0 40px" :underline="false">{{
  76. queryParams.year
  77. }}</el-link>
  78. <el-button link type="primary" icon="ArrowRight" size="small" @click="nextYear" />
  79. </div>
  80. <div style="display: flex; flex-direction: row; margin-right: 20px">
  81. <div v-for="item in selectStatus" :key="item.value"
  82. style="display: flex; flex-direction: row; margin-right: 10px">
  83. <div :style="{
  84. backgroundColor: item.color,
  85. width: '14px',
  86. height: '14px',
  87. margin: 'auto',
  88. borderRadius: '50%',
  89. border: item.color === '#fff' ? '1px solid #ddd' : 'none',
  90. }" />
  91. <div style="
  92. display: inline-block;
  93. margin-left: 10px;
  94. line-height: 36px;
  95. ">
  96. {{ item.label }}
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <el-table-column v-for="item in selectMonths" :key="item.value" min-width="50" :label="item.label"
  103. align="center">
  104. <template #default="scope">
  105. <el-button size="small" :style="monthStatusStyle(scope.row, item.value)" circle
  106. @click="openDetail(scope.row, item)" style="width: 12px; height: 12px" />
  107. </template>
  108. </el-table-column>
  109. </el-table-column>
  110. <el-table-column label="执行人" align="center" prop="serviceName" min-width="100">
  111. </el-table-column>
  112. </el-table>
  113. <!-- 分页 -->
  114. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  115. v-model:limit="queryParams.pageSize" @pagination="getList" />
  116. <form-dialog ref="formDialogRef" :get-list="getList" @getList = "getList"/>/>
  117. <view-dialog ref="viewDialogRef" :get-list="getList" />
  118. <import-excel-dialog ref="importExcelDialogRef" :get-list="getList" />
  119. <!-- 更多搜索弹窗 -->
  120. <el-dialog title="更多搜索" v-model="moreSearch" width="620px" append-to-body draggable :close-on-click-modal = "false">
  121. <el-form :model="queryParams" ref="queryRef" size="small" label-width="100">
  122. <el-row :gutter="20">
  123. <el-col :span="12">
  124. <el-form-item label="客户名称:" prop="companyName">
  125. <el-input v-model="queryParams.companyName" size="small" placeholder="请输入客户名称" clearable
  126. @keyup.enter="handleQuery" />
  127. </el-form-item>
  128. <el-form-item v-if="tenant.versionId === '4'" label="来源:">
  129. <el-input size="small" v-model="queryParams.fromCompanyName" type="text" placeholder="客户来源"
  130. :clearable="true" />
  131. </el-form-item>
  132. <el-form-item label="状态:">
  133. <el-select v-model.trim="queryParams.status" prop="status" size="small" type="text" placeholder="状态"
  134. :clearable="true" @clear="clearStatus">
  135. <el-option v-for="item in selectStatus" :key="item.value" :label="item.label" :value="item.value" />
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="12">
  140. <el-form-item label="月份:">
  141. <el-select v-model.trim="queryParams.month" size="small" placeholder="月份" @change="handleQuery"
  142. :clearable="false">
  143. <el-option v-for="item in selectMonths" :key="item.value" :label="item.label" :value="item.value" />
  144. </el-select>
  145. </el-form-item>
  146. <el-form-item label="纳税性质:">
  147. <el-select size="small" v-model="queryParams.taxType" placeholder="请选择纳税性质" :clearable="true"
  148. @change="taxTypeChange">
  149. <el-option v-for="item in taxTypes" :key="item.label" :label="item.label" :value="item.value" />
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. </el-row>
  154. </el-form>
  155. <template #footer>
  156. <div class="dialog-footer">
  157. <el-button type="primary" icon="Finished" size="small" @click="handleQuery">确 定</el-button>
  158. <el-button icon="close" size="small" @click="moreSearch = false">取 消</el-button>
  159. </div>
  160. </template>
  161. </el-dialog>
  162. </div>
  163. </template>
  164. <script setup name="Company">
  165. import useUserStore from "@/store/modules/user";
  166. import { taxTypes } from "@/utils/default";
  167. import { listSalary, exportSalary } from "@/api/business/production/salaryZero";
  168. import { listCompany } from "@/api/business/crm/company";
  169. import importExcelDialog from "./importExcelDialog.vue";
  170. import { compile, reactive, ref, toRefs } from "vue";
  171. import formDialog from "./form";
  172. import viewDialog from "./view";
  173. // import workorderForm from "./form"
  174. const { proxy } = getCurrentInstance();
  175. /** 字典数组区 */
  176. /** 查询 对象 */
  177. const tenant = useUserStore().tenant;
  178. const list = ref([]);
  179. const oneself = ref(false);
  180. const importExcelDialogRef = ref(null);
  181. const loading = ref(true);
  182. const ids = ref([]);
  183. const single = ref(true);
  184. const multiple = ref(true);
  185. const moreSearch = ref(false);
  186. const total = ref(0);
  187. const prev = ref([]);
  188. const permissions = useUserStore().permissions;
  189. const all_permission = "*:*:*";
  190. const data = reactive({
  191. selectMonths: [
  192. {
  193. label: "一月",
  194. value: "01",
  195. },
  196. {
  197. label: "二月",
  198. value: "02",
  199. },
  200. {
  201. label: "三月",
  202. value: "03",
  203. },
  204. {
  205. label: "四月",
  206. value: "04",
  207. },
  208. {
  209. label: "五月",
  210. value: "05",
  211. },
  212. {
  213. label: "六月",
  214. value: "06",
  215. },
  216. {
  217. label: "七月",
  218. value: "07",
  219. },
  220. {
  221. label: "八月",
  222. value: "08",
  223. },
  224. {
  225. label: "九月",
  226. value: "09",
  227. },
  228. {
  229. label: "十月",
  230. value: "10",
  231. },
  232. {
  233. label: "十一月",
  234. value: "11",
  235. },
  236. {
  237. label: "十二月",
  238. value: "12",
  239. },
  240. ],
  241. selectStatus: [
  242. {
  243. label: "未开始",
  244. value: 0,
  245. color: "#fff",
  246. },
  247. {
  248. label: "待确认",
  249. value: 1,
  250. color: "#ffb836",
  251. },
  252. {
  253. label: "待审核",
  254. value: 2,
  255. color: "#0F8BFF",
  256. },
  257. {
  258. label: "已完成",
  259. value: 3,
  260. color: "#2FCB81",
  261. },
  262. {
  263. label: "驳回待处理",
  264. value: 4,
  265. color: "#E63E3E",
  266. },
  267. ],
  268. });
  269. const { selectStatus, selectMonths } = toRefs(data);
  270. const flag = ref(checkPermission(['business:wage:person']))
  271. const formDialogRef = ref(null);
  272. const viewDialogRef = ref(null);
  273. const activeName = flag.value ? ref('first') : ref('second');
  274. const form = ref({
  275. id: null,
  276. companyName: "",
  277. companyId: null,
  278. remark: "",
  279. type: 1,
  280. });
  281. const emptyForm = {
  282. id: null,
  283. companyName: "",
  284. companyId: null,
  285. type: 2,
  286. remark: "",
  287. noContract: 1,
  288. };
  289. /** 查询对象 */
  290. const queryParams = ref({
  291. pageNum: 1,
  292. pageSize: 20,
  293. orderByColumn: "create_time",
  294. year: proxy.moment().subtract(1, "month").format("yyyy"),
  295. month: proxy.moment().subtract(1, "month").format("MM"),
  296. companyName: "",
  297. principal: tenant.versionId !== '4' && !flag.value ? useUserStore().user.userId : null,
  298. });
  299. const editStatus = {
  300. startMonth: false,
  301. };
  302. /*********************** 方法区 ****************************/
  303. /** 查询company列表 */
  304. function getList() {
  305. loading.value = true;
  306. listSalary(queryParams.value).then((response) => {
  307. list.value = response.rows;
  308. total.value = response.total;
  309. loading.value = false;
  310. });
  311. }
  312. function handleClick(tab) {
  313. console.log(tab.props.name)
  314. if (tab.props.name === "second") {
  315. oneself.value = true
  316. handleOneself()
  317. } else {
  318. oneself.value = false
  319. handleOneself()
  320. }
  321. }
  322. /** 是否为自己负责 */
  323. function handleOneself() {
  324. if (oneself.value) {
  325. queryParams.value.principal = useUserStore().user.userId;
  326. } else {
  327. queryParams.value.principal = null;
  328. }
  329. getList();
  330. }
  331. function checkPermission(templatePermission) {
  332. const all_permission = "*:*:*";
  333. const permissions = useUserStore().permissions;
  334. const hasPermissions = permissions.some((permission) => {
  335. return (
  336. all_permission === permission || templatePermission.includes(permission)
  337. );
  338. });
  339. return hasPermissions;
  340. }
  341. /** 搜索按钮操作 */
  342. function handleQuery() {
  343. queryParams.value.pageNum = 1;
  344. getList();
  345. moreSearch.value = false;
  346. }
  347. /** 重置按钮操作 */
  348. function resetQuery() {
  349. // proxy.resetForm("queryRef");
  350. queryParams.value = {
  351. pageNum: 1,
  352. pageSize: 20,
  353. year: proxy.moment().subtract(1, "month").format("yyyy"),
  354. month: proxy.moment().subtract(1, "month").format("MM"),
  355. companyName: "",
  356. };
  357. if (activeName.value != null && activeName.value === 'second') {
  358. queryParams.value.principal = useUserStore().user.userId;
  359. }
  360. handleQuery();
  361. }
  362. // 多选框选中数据
  363. function handleSelectionChange(selection) {
  364. ids.value = selection.map((item) => item.id);
  365. single.value = selection.length != 1;
  366. multiple.value = !selection.length;
  367. }
  368. function reset() {
  369. form.value = proxy.deepClone(emptyForm);
  370. }
  371. /** 修改按钮操作 */
  372. function handleUpdate(row) {
  373. // const id = row.id || ids.value;
  374. // proxy.$refs.workOrderRef.open(id);
  375. }
  376. function openDetail(row, month) {
  377. // 判断选中月的状态
  378. const index = row.details.findIndex((l) => l.month == month.value);
  379. if (index >= 0) {
  380. const detail = row.details[index];
  381. directDialog(detail);
  382. } else {
  383. const detail = {
  384. financialSalaryId: row.id,
  385. companyId: row.companyId,
  386. companyName: row.companyName,
  387. month: month.value,
  388. year: queryParams.value.year,
  389. };
  390. directDialog(detail);
  391. }
  392. }
  393. function directDialog(detail) {
  394. // 判断是否有权限
  395. if (detail.status === 0 || detail.status == null || detail.status === 1) {
  396. if (editable()) {
  397. formDialogRef.value.open(detail);
  398. } else {
  399. proxy.$modal.msgError("没有权限");
  400. }
  401. } else if (detail.status === 4) {
  402. if (editable()) {
  403. formDialogRef.value.open(detail);
  404. } else if (viewable() || verifiable()) {
  405. viewDialogRef.value.open(detail);
  406. } else {
  407. proxy.$modal.msgError("没有权限");
  408. }
  409. } else if (detail.status === 2 || detail.status === 3) {
  410. if (editable() || viewable() || verifiable()) {
  411. viewDialogRef.value.open(detail);
  412. } else {
  413. proxy.$modal.msgError("没有权限");
  414. }
  415. }
  416. }
  417. function viewable() {
  418. return (
  419. permissions.includes(all_permission) ||
  420. permissions.includes("business:salaryZero:view")
  421. );
  422. }
  423. function editable() {
  424. return (
  425. permissions.includes(all_permission) ||
  426. permissions.includes("business:salaryZero:edit")
  427. );
  428. }
  429. function verifiable() {
  430. return (
  431. permissions.includes(all_permission) ||
  432. permissions.includes("business:salaryZero:verify")
  433. );
  434. }
  435. /** 导出按钮操作 */
  436. function handleExport() {
  437. exportSalary(queryParams.value);
  438. }
  439. //导入按钮操作
  440. function handleImport() {
  441. importExcelDialogRef.value.open();
  442. }
  443. function startDateChangeHandler(row, startDate) {
  444. if (startDate) {
  445. // console.log(startDate)
  446. row.endMonth = proxy
  447. .moment(startDate)
  448. .add(row.monthNum - 1, "M")
  449. .format("YYYY-MM-DD");
  450. } else row.endMonth = null;
  451. // console.log(row)
  452. }
  453. function prevYear() {
  454. let currentYear = queryParams.value.year;
  455. currentYear = Number(currentYear) - 1;
  456. queryParams.value.year = currentYear.toString();
  457. handleQuery();
  458. }
  459. function nextYear() {
  460. let currentYear = queryParams.value.year;
  461. currentYear = Number(currentYear) + 1;
  462. queryParams.value.year = currentYear.toString();
  463. handleQuery();
  464. }
  465. function monthStatusStyle(row, month) {
  466. const index = row.details.findIndex((v) => v.month === month);
  467. if (index >= 0) {
  468. return {
  469. backgroundColor: getStatusColor(row.details[index].status),
  470. verticalAlign: "middle",
  471. width: "14px",
  472. height: "14px",
  473. };
  474. } else {
  475. return {
  476. backgroundColor: getStatusColor(0),
  477. verticalAlign: "middle",
  478. width: "14px",
  479. height: "14px",
  480. };
  481. }
  482. }
  483. function getStatusColor(status) {
  484. const index = selectStatus.value.findIndex((v) => v.value === status);
  485. return index >= 0 ? selectStatus.value[index].color : "#fff";
  486. }
  487. function clearStatus() {
  488. queryParams.value.status = null;
  489. }
  490. getList();
  491. </script>