index.vue 17 KB

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