index.vue 13 KB

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