index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. <el-button v-hasPermi="['business:entrust:workOrder:base:edit']" style="margin-left: 5px;" type="danger" size="small" icon="remove" @click="stopWorkOrder">停用</el-button>
  25. </div>
  26. <!-- 搜索区 -->
  27. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  28. label-width="68px">
  29. <el-form-item label="当前月:">{{
  30. moment().format("YYYY年MM月")
  31. }}</el-form-item>
  32. <el-form-item label="客户名称:" prop="companyName">
  33. <el-input v-model="queryParams.companyName" style="width: 150px" placeholder="请输入客户名称" clearable
  34. @keyup.enter="handleQuery" />
  35. </el-form-item>
  36. <el-form-item label="执行人:" prop="toAccountName">
  37. <el-input v-model="queryParams.toAccountName" placeholder="请输入执行人" clearable @keyup.enter="handleQuery" />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  41. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <!-- 列表区 -->
  45. <el-table v-loading="loading" :data="list" size="small" border height="100%"
  46. @selection-change="handleSelectionChange">
  47. <el-table-column type="selection" width="55" align="center" />
  48. <!-- <el-table-column label="工单号" align="center" prop="workOrderNo" width="200" /> -->
  49. <el-table-column label="客户名称" align="center" min-width="250" prop="companyName" >
  50. <template #default="scope">
  51. <div style="display: flex; align-items: center; ">
  52. <template v-if="scope.row.entrustExamine && scope.row.entrustExamine.status == 0">
  53. <el-tooltip content="等待取消委托确认" placement="top">
  54. <el-icon :size="15">
  55. <Clock />
  56. </el-icon>
  57. </el-tooltip>
  58. <span style="padding-left:5px;">{{ scope.row.companyName }}</span>
  59. </template>
  60. <template v-else-if="scope.row.entrustExamine && scope.row.entrustExamine.status == 2">
  61. <el-tooltip :content="str+scope.row.entrustExamine.refuseReason" placement="top">
  62. <el-icon :size="15" color="#E22121">
  63. <WarnTriangleFilled />
  64. </el-icon>
  65. </el-tooltip>
  66. <span style="padding-left:5px;">{{ scope.row.companyName }}</span>
  67. </template>
  68. <template v-else>
  69. <div style="width: 20px; height: 15px;"></div>
  70. <span>{{ scope.row.companyName }}</span>
  71. </template>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="税号" align="center" prop="socialCreditCode" min-width="200" />
  76. <el-table-column label="工单类型" align="center" prop="amount" min-width="80">
  77. <template #default="scope">
  78. {{ scope.row.type === 1 ? "循环工单" : "代办工单" }}
  79. </template>
  80. </el-table-column>
  81. <el-table-column v-if="list.findIndex((v) => v.tenantId !== tenantId) >= 0" label="来源" align="center"
  82. prop="fromCompanyName" min-width="80">
  83. </el-table-column>
  84. <el-table-column label="项目" align="center" prop="taskTypeName" min-width="140">
  85. <template #default="scope">
  86. {{ scope.row.taskTypeName }}
  87. {{
  88. scope.row.taskTypeDetailName
  89. ? `-${scope.row.taskTypeDetailName}`
  90. : ""
  91. }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="起始月" align="center" width="90" min-prop="startMonth">
  95. <template #default="scope">
  96. {{
  97. scope.row.type === 1
  98. ? scope.row.startMonth
  99. ? moment(scope.row.startMonth).format("YYYY年MM月")
  100. : ""
  101. : "-"
  102. }}
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="结束月" align="center" min-width="90" prop="endMonth">
  106. <template #default="scope">
  107. {{
  108. scope.row.type === 1
  109. ? scope.row.endMonth
  110. ? moment(scope.row.endMonth).format("YYYY年MM月")
  111. : ""
  112. : "-"
  113. }}
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="工单月数" align="center" min-width="80" prop="monthNum">
  117. <template #default="scope">
  118. {{ scope.row.type === 1 ? scope.row.monthNum : "-" }}
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="工单执行人" align="center" min-width="100">
  122. <template #default="scope">
  123. {{
  124. scope.row.entrust != null
  125. ? scope.row.entrust.toAccountName
  126. : scope.row.serviceName
  127. }}
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <!-- <contract-form ref="contractRef" :get-list="getList" /> -->
  132. <!-- 分页 -->
  133. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  134. v-model:limit="queryParams.pageSize" @pagination="getList" />
  135. <init-month-dialog ref="initMonthDialogRef" :get-list="checkCurrentMonthHandle"
  136. :setCurrentMonth="setCurrentMonth" />
  137. <set-entrust-dialog ref="setEntrustDialogRef" :get-list="getList" @submit="handleAddEntrust" />
  138. <exports ref="exportRef" :get-list="getList"></exports>
  139. <el-dialog title="取消委托" v-model="cancelEntrust" width="720px" append-to-body size="small" draggable
  140. :close-on-click-modal="false">
  141. <span style="font-size: 12px;">
  142. {{companyName}} 的服务工厂已经开始了任务,需要工厂确认才可以取消,请填写取消理由
  143. </span>
  144. <el-form-item label="取消理由" prop="cancelReason" style="margin-top: 10px" >
  145. <el-input v-model="form.cancelReason" type="textarea" placeholder="请输入取消理由" />
  146. </el-form-item>
  147. <template #footer>
  148. <div class="dialog-footer">
  149. <el-button type="primary" icon="Finished" size="small" @click="submitForm">确 定</el-button>
  150. <el-button icon="close" size="small" @click="cancelEntrust = false">取 消</el-button>
  151. </div>
  152. </template>
  153. </el-dialog>
  154. </div>
  155. </template>
  156. <script setup name="CurrentMonthWorkOrder">
  157. import InitMonthDialog from "../initMonthDialog";
  158. import exports from "./export.vue"
  159. import { getToken, getTenant } from "@/utils/auth";
  160. import {
  161. listCurrentWorkOrder,
  162. checkCurrent,
  163. exportCurrentWorkOrder,
  164. delEntrust,
  165. transNext,
  166. addEntrust, exportStore,saveExamine,stopWorkOrderApi
  167. } from "@/api/business/entrust/currentWorkOrder";
  168. import SetEntrustDialog from "../setEntrustDialog";
  169. import useUserStore from "@/store/modules/user";
  170. // import { ca } from "element-plus/es/locale";
  171. const { proxy } = getCurrentInstance();
  172. const currentMonth = ref(null);
  173. /** 字典数组区 */
  174. /** 查询 对象 */
  175. const list = ref([]);
  176. const loading = ref(true);
  177. const cancel = ref(true);
  178. const multiple = ref(true);
  179. const ids = ref([]);
  180. const selections = ref([]);
  181. const single = ref(false);
  182. const total = ref(0);
  183. const prev = ref([]);
  184. const tenantId = ref(getTenant());
  185. const permissions = useUserStore().permissions;
  186. const all_permission = "*:*:*";
  187. const str = ref("拒绝取消委托,原因:")
  188. const form = ref({});
  189. const initMonthDialogRef = ref(null);
  190. const setEntrustDialogRef = ref(null);
  191. const companyName = ref(null);
  192. const showInitMonth = ref(false);
  193. const cancelEntrust = ref(false);
  194. const { contract_verify_status } = proxy.useDict("contract_verify_status");
  195. const { contract_status } = proxy.useDict("contract_status");
  196. /** 查询对象 */
  197. const queryParams = ref({
  198. pageNum: 1,
  199. pageSize: 20,
  200. companyName: "",
  201. orderByColumn: "create_time",
  202. noContract: 0,
  203. type: 1,
  204. });
  205. const editStatus = {
  206. startMonth: false,
  207. };
  208. function checkCurrentMonthHandle() {
  209. checkCurrent().then((res) => {
  210. if (res.data.checkResult === true) {
  211. setCurrentMonth(res.data.currentMonth);
  212. getList();
  213. } else {
  214. showInitMonthDialog();
  215. }
  216. });
  217. }
  218. function showInitMonthDialog() {
  219. initMonthDialogRef.value.open();
  220. }
  221. /*********************** 方法区 ****************************/
  222. /** 查询company列表 */
  223. function getList() {
  224. loading.value = true;
  225. queryParams.value.currentMonth = currentMonth.value;
  226. listCurrentWorkOrder(queryParams.value).then((response) => {
  227. list.value = response.rows;
  228. console.log(response);
  229. total.value = response.total;
  230. loading.value = false;
  231. });
  232. }
  233. onActivated(() => {
  234. // 你的逻辑
  235. getList();
  236. });
  237. //判断是否有权限
  238. function viewAdviser(quer) {
  239. return permissions.includes(all_permission) || permissions.includes(quer);
  240. }
  241. /** 搜索按钮操作 */
  242. function handleQuery() {
  243. queryParams.value.pageNum = 1;
  244. getList();
  245. }
  246. /** 重置按钮操作 */
  247. function resetQuery() {
  248. proxy.resetForm("queryRef");
  249. handleQuery();
  250. }
  251. /** 新增导入操作 */
  252. function exportZero() {
  253. proxy.$refs.exportRef.open();
  254. }
  255. function submitForm() {
  256. if (form.value.cancelReason == undefined || form.value.cancelReason == "") {
  257. proxy.$modal.msgError("请输入取消原因");
  258. }
  259. form.value.workMonth = currentMonth.value,
  260. loading.value = true;
  261. saveExamine(form.value).then((res) => {
  262. proxy.$modal.msgSuccess("取消成功");
  263. cancelEntrust.value = false
  264. getList();
  265. }).finally(() => {
  266. loading.value = false;
  267. })
  268. }
  269. // 多选框选中数据
  270. function handleSelectionChange(selection) {
  271. ids.value = selection.map((item) => item.id);
  272. selections.value = selection;
  273. //取消委托计数
  274. let cancelNum = 0;
  275. //设置委托计数
  276. let multipleNum = 0;
  277. //判断是否有执行人
  278. selections.value.forEach((item) => {
  279. if (item.entrust) {
  280. //有执行人
  281. if (item.entrust.toAccountName) {
  282. cancelNum++;
  283. }
  284. }
  285. //没有执行人
  286. if (!item.entrust) {
  287. multipleNum++;
  288. }
  289. });
  290. //判断是否有选中数据
  291. if (!selections.value.length > 0) {
  292. multiple.value = true;
  293. cancel.value = true;
  294. } //判断是否设置执行人和设置委托选中
  295. else if (cancelNum > 0 && multipleNum > 0) {
  296. cancel.value = cancelNum > 0;
  297. multiple.value = multipleNum > 0;
  298. } else {
  299. cancel.value = !cancelNum > 0;
  300. multiple.value = !multipleNum > 0;
  301. }
  302. }
  303. /** 导出按钮操作 */
  304. function handleExport() {
  305. exportStore(queryParams.value);
  306. }
  307. function setCurrentMonth(month) {
  308. // currentMonth.value = month;
  309. currentMonth.value = proxy.moment().format("YYYY-MM") + "-01";
  310. }
  311. function setEntrustHandle() {
  312. setEntrustDialogRef.value.open({
  313. selections: selections.value,
  314. optionCurrentMonth: currentMonth.value,
  315. });
  316. }
  317. function delEntrustHandle() {
  318. const entrust = {
  319. workMonth: currentMonth.value,
  320. workOrderIds: ids.value,
  321. };
  322. proxy.$modal.confirm("是否确认取消委托?").then(() => {
  323. loading.value = true; //
  324. delEntrust(entrust).then((res) => {
  325. if (res.data != null) {
  326. companyName.value = res.data.companyName
  327. form.value.workOrderIds = res.data.workOrderIds
  328. // res.data.com
  329. cancelEntrust.value = true;
  330. } else {
  331. proxy.$modal.msgSuccess("取消成功");
  332. getList();
  333. }
  334. loading.value = false;
  335. }).catch(() => {
  336. }).finally(() => {
  337. loading.value = false; // 确保在请求完成时也关闭加载状态
  338. })
  339. });
  340. }
  341. function transEntrustHandler() {
  342. proxy.$modal.confirm("确定流转到下一月?").then(() => {
  343. transNext().then((res) => {
  344. proxy.$modal.msgSuccess("流转成功");
  345. checkCurrentMonthHandle();
  346. });
  347. });
  348. // let currentDate = new Date().getMonth() + 1;
  349. // let formattedMonth = currentDate.toString().padStart(2, '0');
  350. // let month = currentMonth.value.split('-')[1];
  351. // console.log(formattedMonth);
  352. // if (month < formattedMonth) {
  353. // proxy.$modal.confirm("确定流转到下一月?").then(() => {
  354. // transNext().then((res) => {
  355. // proxy.$modal.msgSuccess("流转成功");
  356. // checkCurrentMonthHandle();
  357. // });
  358. // });
  359. // } else {
  360. // // //真实月 != 当前月
  361. // if (month != formattedMonth) {
  362. // proxy.$modal.msgError("每月只可流转一次");
  363. // } else {
  364. // let currentDay = new Date().getDate()
  365. // let cutoffDay = 20;
  366. // //如果当前月时间小于20号
  367. // if (currentDay < cutoffDay) {
  368. // proxy.$modal.msgError("每月20号后才能流转");
  369. // } else {
  370. // proxy.$modal.confirm("确定流转到下一月?").then(() => {
  371. // transNext().then((res) => {
  372. // proxy.$modal.msgSuccess("流转成功");
  373. // checkCurrentMonthHandle();
  374. // });
  375. // });
  376. // }
  377. // }
  378. // }
  379. }
  380. function handleAddEntrust(data) {
  381. addEntrust(data).then((response) => {
  382. proxy.$modal.msgSuccess("设置完成!");
  383. setEntrustDialogRef.value.cancel();
  384. getList();
  385. });
  386. }
  387. checkCurrentMonthHandle();
  388. const stopWorkOrder = ()=>{
  389. loading.value = true;
  390. proxy.$modal.confirm("是否确认停用工单?").then(() => {
  391. loading.value = false;
  392. stopWorkOrderApi(selections.value).then((res)=>{
  393. proxy.$modal.msgSuccess("停用成功");
  394. getList();
  395. })
  396. }).catch((e) => {
  397. }).finally(() => {
  398. loading.value = false; // 确保在请求完成时也关闭加载状态
  399. })
  400. }
  401. </script>