index.vue 14 KB

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