index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <el-button type="primary" size="small" icon="Plus" :disabled="multiple" @click="setEntrustHandle"
  6. v-hasPermi="['business:entrust:workOrder:current:edit']">设置委托</el-button>
  7. <el-button type="danger" size="small" icon="delete" :disabled="cancel" @click="delEntrustHandle"
  8. v-hasPermi="['business:entrust:workOrder:current:edit']">取消委托</el-button>
  9. <!-- <el-button type="success" size="small" icon="Refresh" @click="transEntrustHandler"
  10. v-hasPermi="['business:entrust:workOrder:current:trans']">委托流转11</el-button> -->
  11. <el-dropdown trigger="click">
  12. <el-button type="primary" size="small">
  13. 其它<el-icon class="el-icon--right"><arrow-down /></el-icon>
  14. </el-button>
  15. <template #dropdown>
  16. <el-dropdown-menu>
  17. <el-dropdown-item icon="Download" @click="handleExport"
  18. v-if="viewAdviser('business:entrust:workOrder:current:export')">
  19. 导出</el-dropdown-item>
  20. </el-dropdown-menu>
  21. </template>
  22. </el-dropdown>
  23. <el-button style="margin-left: 5px;" type="primary" size="small" icon="Plus" @click="exportZero">导入委托</el-button>
  24. </div>
  25. <!-- 搜索区 -->
  26. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  27. label-width="68px">
  28. <el-form-item label="当前月:">{{
  29. currentMonth == null
  30. ? "未设定本月"
  31. : moment().format("YYYY年MM月")
  32. }}</el-form-item>
  33. <el-form-item label="客户名称:" prop="companyName">
  34. <el-input v-model="queryParams.companyName" style="width: 150px" placeholder="请输入客户名称" clearable
  35. @keyup.enter="handleQuery" />
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  39. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  40. </el-form-item>
  41. </el-form>
  42. <!-- 列表区 -->
  43. <el-table v-loading="loading" :data="list" size="small" border height="100%"
  44. @selection-change="handleSelectionChange">
  45. <el-table-column type="selection" width="55" align="center" />
  46. <!-- <el-table-column label="工单号" align="center" prop="workOrderNo" width="200" /> -->
  47. <el-table-column label="客户名称" align="center" min-width="250" prop="companyName" />
  48. <el-table-column label="税号" align="center" prop="socialCreditCode" min-width="200" />
  49. <el-table-column label="工单类型" align="center" prop="amount" min-width="80">
  50. <template #default="scope">
  51. {{ scope.row.type === 1 ? "循环工单" : "代办工单" }}
  52. </template>
  53. </el-table-column>
  54. <el-table-column v-if="list.findIndex((v) => v.tenantId !== tenantId) >= 0" label="来源" align="center"
  55. prop="fromCompanyName" min-width="80">
  56. </el-table-column>
  57. <el-table-column label="项目" align="center" prop="taskTypeName" min-width="140">
  58. <template #default="scope">
  59. {{ scope.row.taskTypeName }}
  60. {{
  61. scope.row.taskTypeDetailName
  62. ? `-${scope.row.taskTypeDetailName}`
  63. : ""
  64. }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="起始月" align="center" width="90" min-prop="startMonth">
  68. <template #default="scope">
  69. {{
  70. scope.row.type === 1
  71. ? scope.row.startMonth
  72. ? moment(scope.row.startMonth).format("YYYY年MM月")
  73. : ""
  74. : "-"
  75. }}
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="结束月" align="center" min-width="90" prop="endMonth">
  79. <template #default="scope">
  80. {{
  81. scope.row.type === 1
  82. ? scope.row.endMonth
  83. ? moment(scope.row.endMonth).format("YYYY年MM月")
  84. : ""
  85. : "-"
  86. }}
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="工单月数" align="center" min-width="80" prop="monthNum">
  90. <template #default="scope">
  91. {{ scope.row.type === 1 ? scope.row.monthNum : "-" }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="工单执行人" align="center" min-width="100">
  95. <template #default="scope">
  96. {{
  97. scope.row.entrust != null
  98. ? scope.row.entrust.toAccountName
  99. : scope.row.serviceName
  100. }}
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <!-- <contract-form ref="contractRef" :get-list="getList" /> -->
  105. <!-- 分页 -->
  106. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  107. v-model:limit="queryParams.pageSize" @pagination="getList" />
  108. <init-month-dialog ref="initMonthDialogRef" :get-list="checkCurrentMonthHandle"
  109. :setCurrentMonth="setCurrentMonth" />
  110. <set-entrust-dialog ref="setEntrustDialogRef" :get-list="getList" @submit="handleAddEntrust" />
  111. <exports ref="exportRef" :get-list="getList"></exports>
  112. </div>
  113. </template>
  114. <script setup name="Company">
  115. import InitMonthDialog from "../initMonthDialog";
  116. import exports from "./export.vue"
  117. import { getToken, getTenant } from "@/utils/auth";
  118. import {
  119. listCurrentWorkOrder,
  120. checkCurrent,
  121. exportCurrentWorkOrder,
  122. delEntrust,
  123. transNext,
  124. addEntrust,
  125. } from "@/api/business/entrust/currentWorkOrder";
  126. import SetEntrustDialog from "../setEntrustDialog";
  127. import useUserStore from "@/store/modules/user";
  128. // import { ca } from "element-plus/es/locale";
  129. const { proxy } = getCurrentInstance();
  130. const currentMonth = ref(null);
  131. /** 字典数组区 */
  132. /** 查询 对象 */
  133. const list = ref([]);
  134. const loading = ref(true);
  135. const cancel = ref(true);
  136. const multiple = ref(true);
  137. const ids = ref([]);
  138. const selections = ref([]);
  139. const single = ref(false);
  140. const total = ref(0);
  141. const prev = ref([]);
  142. const tenantId = ref(getTenant());
  143. const permissions = useUserStore().permissions;
  144. const all_permission = "*:*:*";
  145. const initMonthDialogRef = ref(null);
  146. const setEntrustDialogRef = ref(null);
  147. const showInitMonth = ref(false);
  148. const { contract_verify_status } = proxy.useDict("contract_verify_status");
  149. const { contract_status } = proxy.useDict("contract_status");
  150. /** 查询对象 */
  151. const queryParams = ref({
  152. pageNum: 1,
  153. pageSize: 20,
  154. companyName: "",
  155. orderByColumn: "create_time",
  156. noContract: 0,
  157. type: 1,
  158. });
  159. const editStatus = {
  160. startMonth: false,
  161. };
  162. function checkCurrentMonthHandle() {
  163. checkCurrent().then((res) => {
  164. if (res.data.checkResult === true) {
  165. setCurrentMonth(res.data.currentMonth);
  166. getList();
  167. } else {
  168. showInitMonthDialog();
  169. }
  170. });
  171. }
  172. function showInitMonthDialog() {
  173. initMonthDialogRef.value.open();
  174. }
  175. /*********************** 方法区 ****************************/
  176. /** 查询company列表 */
  177. function getList() {
  178. loading.value = true;
  179. queryParams.value.currentMonth = currentMonth.value;
  180. listCurrentWorkOrder(queryParams.value).then((response) => {
  181. list.value = response.rows;
  182. console.log(response);
  183. total.value = response.total;
  184. loading.value = false;
  185. });
  186. }
  187. //判断是否有权限
  188. function viewAdviser(quer) {
  189. return permissions.includes(all_permission) || permissions.includes(quer);
  190. }
  191. /** 搜索按钮操作 */
  192. function handleQuery() {
  193. queryParams.value.pageNum = 1;
  194. getList();
  195. }
  196. /** 重置按钮操作 */
  197. function resetQuery() {
  198. proxy.resetForm("queryRef");
  199. handleQuery();
  200. }
  201. /** 新增导入操作 */
  202. function exportZero() {
  203. proxy.$refs.exportRef.open();
  204. }
  205. // 多选框选中数据
  206. function handleSelectionChange(selection) {
  207. ids.value = selection.map((item) => item.id);
  208. selections.value = selection;
  209. //取消委托计数
  210. let cancelNum = 0;
  211. //设置委托计数
  212. let multipleNum = 0;
  213. //判断是否有执行人
  214. selections.value.forEach((item) => {
  215. if (item.entrust) {
  216. //有执行人
  217. if (item.entrust.toAccountName) {
  218. cancelNum++;
  219. }
  220. }
  221. //没有执行人
  222. if (!item.entrust) {
  223. multipleNum++;
  224. }
  225. });
  226. //判断是否有选中数据
  227. if (!selections.value.length > 0) {
  228. multiple.value = true;
  229. cancel.value = true;
  230. } //判断是否设置执行人和设置委托选中
  231. else if (cancelNum > 0 && multipleNum > 0) {
  232. cancel.value = cancelNum > 0;
  233. multiple.value = multipleNum > 0;
  234. } else {
  235. cancel.value = !cancelNum > 0;
  236. multiple.value = !multipleNum > 0;
  237. }
  238. }
  239. /** 导出按钮操作 */
  240. function handleExport() {
  241. exportCurrentWorkOrder(queryParams.value);
  242. }
  243. function setCurrentMonth(month) {
  244. currentMonth.value = month;
  245. }
  246. function setEntrustHandle() {
  247. setEntrustDialogRef.value.open({
  248. selections: selections.value,
  249. optionCurrentMonth: currentMonth.value,
  250. });
  251. }
  252. function delEntrustHandle() {
  253. const entrust = {
  254. workMonth: currentMonth.value,
  255. workOrderIds: ids.value,
  256. };
  257. proxy.$modal.confirm("是否确认取消委托?").then(() => {
  258. delEntrust(entrust).then((res) => {
  259. proxy.$modal.msgSuccess("取消成功");
  260. getList();
  261. });
  262. });
  263. }
  264. function transEntrustHandler() {
  265. // proxy.$modal.confirm("确定流转到下一月?").then(() => {
  266. // transNext().then((res) => {
  267. // proxy.$modal.msgSuccess("流转成功");
  268. // checkCurrentMonthHandle();
  269. // });
  270. // });
  271. let currentDate = new Date().getMonth() + 1;
  272. let formattedMonth = currentDate.toString().padStart(2, '0');
  273. let month = currentMonth.value.split('-')[1];
  274. console.log(formattedMonth);
  275. if (month < formattedMonth) {
  276. proxy.$modal.confirm("确定流转到下一月?").then(() => {
  277. transNext().then((res) => {
  278. proxy.$modal.msgSuccess("流转成功");
  279. checkCurrentMonthHandle();
  280. });
  281. });
  282. } else {
  283. // //真实月 != 当前月
  284. if (month != formattedMonth) {
  285. proxy.$modal.msgError("每月只可流转一次");
  286. } else {
  287. let currentDay = new Date().getDate()
  288. let cutoffDay = 20;
  289. //如果当前月时间小于20号
  290. if (currentDay < cutoffDay) {
  291. proxy.$modal.msgError("每月20号后才能流转");
  292. } else {
  293. proxy.$modal.confirm("确定流转到下一月?").then(() => {
  294. transNext().then((res) => {
  295. proxy.$modal.msgSuccess("流转成功");
  296. checkCurrentMonthHandle();
  297. });
  298. });
  299. }
  300. }
  301. }
  302. }
  303. function handleAddEntrust(data) {
  304. addEntrust(data).then((response) => {
  305. proxy.$modal.msgSuccess("设置完成!");
  306. setEntrustDialogRef.value.cancel();
  307. getList();
  308. });
  309. }
  310. checkCurrentMonthHandle();
  311. </script>