index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <div class="listbutton">
  6. <div>
  7. <el-button type="primary" size="small"
  8. icon="Download" @click="handleExport"
  9. v-hasPermi="['business:upgrade:workOrder:export']">导出
  10. </el-button>
  11. <el-button type="primary" size="small"
  12. @click="OrderDisableForm"
  13. v-hasPermi="['business:upgrade:workOrder:edit']">停用
  14. </el-button>
  15. </div>
  16. <el-button type="primary" size="small"
  17. v-loading.fullscreen.lock="fullscreenLoading"
  18. icon="Plus" @click="Upgrade"
  19. v-hasPermi="['business:upgrade:workOrder:edit']">完成升级
  20. </el-button>
  21. </div>
  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="客户名称:" prop="companyName">
  27. <el-input v-model="queryParams.companyName" placeholder="请输入客户名称" style="width: 150px" clearable
  28. @keyup.enter="handleQuery" />
  29. </el-form-item>
  30. <el-form-item label="停用状态:" prop="isStop">
  31. <el-select
  32. size="small"
  33. v-model="queryParams.isStop"
  34. placeholder="停用状态"
  35. clearable
  36. style="width: 90px"
  37. >
  38. <el-option label="是" :value="1"></el-option>
  39. <el-option label="否" selected :value="0"></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  44. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <!-- 列表区 -->
  48. <el-table v-loading="loading" :data="orderList" size="small" border height="100%"
  49. @selection-change="handleSelectionChange">
  50. <el-table-column type="selection" width="55" align="center" />
  51. <el-table-column label="工单编号" align="center" prop="id" min-width="250" />
  52. <el-table-column label="客户名称" align="center" min-width="250" prop="companyName" :resizable="false" />
  53. <el-table-column label="税号" align="center" min-width="200" prop="socialCreditCode" :resizable="false" />
  54. <el-table-column label="工单类型" align="center" prop="amount" min-width="80" :resizable="false">
  55. <template #default="scope">
  56. {{ scope.row.type === 1 ? "循环工单" : "代办工单" }}
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="项目" align="center" prop="taskTypeName" :resizable="false" min-width="110">
  60. <template #default="scope">
  61. {{ scope.row.taskTypeName }}
  62. {{
  63. scope.row.taskTypeDetailName
  64. ? `-${scope.row.taskTypeDetailName}`
  65. : ""
  66. }}
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="是否延续" align="center" prop="isContinue" :resizable="false">
  70. <template #default="scope">
  71. {{ scope.row.isContinue === 0 ? "否" : "是" }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="停用状态" align="center" width="150" prop="socialCreditCode" :resizable="false">
  75. <template #default="scope">
  76. {{ scope.row.isStop === 0 ? "否" : "是" }}
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="起始月" align="center" min-width="120" prop="startMonth" :resizable="false">
  80. <template #default="scope">
  81. <div v-if="scope.row.type === 1">
  82. <div v-if="scope.row.editStatus.startMonth" style="
  83. display: flex;
  84. flex-direction: row;
  85. justify-content: center;
  86. ">
  87. <el-date-picker v-model="scope.row.startMonth" size="small" placeholder="起始月" :clearable="true"
  88. value-format="YYYY-MM-DD" format="YYYY年MM月" type="month"
  89. @change="(arg) => startDateChangeHandler(scope.row, arg)" />
  90. <el-button link type="primary" icon="Check" size="small" style="padding: 0"
  91. @click="saveHandler(scope.row, 'startMonth')" />
  92. </div>
  93. <div v-else style="
  94. display: flex;
  95. flex-direction: row;
  96. justify-content: center;
  97. ">
  98. <div style="width: auto">
  99. {{
  100. scope.row.startMonth
  101. ? moment(scope.row.startMonth).format("YYYY年MM月")
  102. : ""
  103. }}
  104. </div>
  105. <el-button v-show="
  106. scope.row.isStop === 0 && scope.row.records.length === 0 && scope.row.isNew === 1
  107. " link type="primary" icon="Edit" size="small" style="padding: 0"
  108. v-hasPermi="['business:upgrade:workOrder:edit']" @click="
  109. () => {
  110. scope.row.editStatus.startMonth =
  111. !scope.row.editStatus.startMonth;
  112. }
  113. " />
  114. </div>
  115. </div>
  116. <div v-else>-</div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="结束月" align="center" min-width="90" :resizable="false">
  120. <template #default="scope">
  121. <div v-if="scope.row.monthNum > 0">
  122. {{
  123. scope.row.type === 1
  124. ? scope.row.endMonth
  125. ? moment(scope.row.endMonth).format("YYYY年MM月")
  126. : ""
  127. : "-"
  128. }}
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="工单月数" align="center" :resizable="false" width="80" prop="monthNum">
  133. <template #default="scope">
  134. {{ scope.row.type === 1 ? scope.row.monthNum : "-" }}
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="工单执行人" align="center" :resizable="false" min-width="100">
  138. <template #default="scope">{{ getTransactor(scope.row) }}</template>
  139. </el-table-column>
  140. </el-table>
  141. <el-dialog title="新增工单" v-model="formOpen" width="500px" append-to-body draggable>
  142. <el-form ref="dictRef" :model="form" label-width="100" size="small">
  143. <el-row :gutter="30">
  144. <el-col :span="24">
  145. <el-form-item label="客户名称:" prop="companyName">
  146. <el-autocomplete style="width: 100%" fit-input-width="300px" size="small"
  147. :fetch-suggestions="querySearchCompanyAsync" :trigger-on-focus="true" v-model="form.companyName"
  148. placeholder="请输入客户名称" @select="handleSelectCompany">
  149. <template #append>
  150. <el-button icon="Plus" @click="showAddCompanyDialog">
  151. </el-button>
  152. </template>
  153. <template #default="{ item }">
  154. <div style="
  155. display: flex;
  156. flex-direction: row;
  157. justify-content: space-between;
  158. ">
  159. <div class="name" style="font-size: 12px">
  160. {{ item.name }}
  161. </div>
  162. <!-- <span class="code" style="font-size: 10px; color: darkgrey;">{{ item.code }}</span> -->
  163. </div>
  164. </template>
  165. </el-autocomplete>
  166. </el-form-item>
  167. <el-form-item label="服务内容:">
  168. <el-input v-model.trim="form.remark" type="textarea" size="small" :rows="4" maxlength="200"
  169. show-word-limit placeholder="服务内容" :clearable="true" />
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="24"> </el-col>
  173. </el-row>
  174. </el-form>
  175. <template #footer>
  176. <div class="dialog-footer">
  177. <el-button type="primary" icon="Finished" size="small" @click="saveHandler">确 定</el-button>
  178. <el-button @click="formCancel" icon="close" size="small">取 消</el-button>
  179. </div>
  180. </template>
  181. </el-dialog>
  182. <!-- 分页 -->
  183. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  184. v-model:limit="queryParams.pageSize" @pagination="getList" />
  185. <AddCompanyDialog ref="addCompanyDialogRef" />
  186. </div>
  187. </template>
  188. <script setup name="WorkOrder">
  189. // import contractForm from "./form";
  190. import {
  191. listWorkOrder,
  192. delWorkOrder,
  193. exportWorkOrder,
  194. addWorkOrder,
  195. exportNoContract,
  196. completeUpgrade,
  197. checkWorkOrder,
  198. OrderDisable
  199. } from "@/api/upgrade/workOrder";
  200. import { listCompany } from "@/api/business/crm/company";
  201. import AddCompanyDialog from "../AddCompanyDialog.vue";
  202. import { ref } from "vue";
  203. import {ElMessageBox} from "element-plus";
  204. // import workorderForm from "./form"
  205. const { proxy } = getCurrentInstance();
  206. /** 字典数组区 */
  207. /** 查询 对象 */
  208. const orderList = ref([]);
  209. const loading = ref(true);
  210. const ids = ref([]);
  211. const single = ref(true);
  212. const multiple = ref(true);
  213. const total = ref(0);
  214. const prev = ref([]);
  215. const addCompanyDialogRef = ref(null);
  216. const fullscreenLoading = ref(false);
  217. const formOpen = ref(false);
  218. const form = ref({
  219. id: null,
  220. companyName: "",
  221. companyId: null,
  222. remark: "",
  223. type: 2,
  224. noContract: 1,
  225. });
  226. const emptyForm = {
  227. id: null,
  228. companyName: "",
  229. companyId: null,
  230. type: 2,
  231. remark: "",
  232. noContract: 1,
  233. };
  234. const { contract_verify_status } = proxy.useDict("contract_verify_status");
  235. const { contract_status } = proxy.useDict("contract_status");
  236. /** 查询对象 */
  237. const queryParams = ref({
  238. pageNum: 1,
  239. pageSize: 20,
  240. orderByColumn: "create_time",
  241. companyName: "",
  242. noContract: 1,
  243. isStop:0,
  244. });
  245. const editStatus = {
  246. startMonth: false,
  247. };
  248. /*********************** 方法区 ****************************/
  249. onActivated(() => {
  250. // 你的逻辑
  251. getList();
  252. });
  253. /** 查询company列表 */
  254. function getList() {
  255. loading.value = true;
  256. listWorkOrder(queryParams.value).then((response) => {
  257. orderList.value = response.rows.map((l) => ({
  258. ...l,
  259. editStatus: proxy.deepClone(editStatus),
  260. }));
  261. prev.value = proxy.deepClone(response.rows);
  262. total.value = response.total;
  263. loading.value = false;
  264. });
  265. }
  266. function OrderDisableForm(){
  267. if(ids.value.length < 1) {
  268. proxy.$modal
  269. .msgError("请选择数据")
  270. return;
  271. }
  272. OrderDisable(ids.value).then((response) => {
  273. proxy.$modal.msgSuccess('停用成功');
  274. getList();
  275. });
  276. }
  277. /** 搜索按钮操作 */
  278. function handleQuery() {
  279. queryParams.value.pageNum = 1;
  280. getList();
  281. }
  282. /** 重置按钮操作 */
  283. function resetQuery() {
  284. proxy.resetForm("queryRef");
  285. handleQuery();
  286. }
  287. // 多选框选中数据
  288. function handleSelectionChange(selection) {
  289. ids.value = selection.map((item) => item.id);
  290. single.value = selection.length != 1;
  291. multiple.value = !selection.length;
  292. }
  293. /** 新增按钮操作 */
  294. function handleAdd() {
  295. // proxy.$refs.workOrderRef.open();
  296. formOpen.value = true;
  297. }
  298. function formCancel() {
  299. formOpen.value = false;
  300. reset();
  301. }
  302. function reset() {
  303. form.value = proxy.deepClone(emptyForm);
  304. }
  305. /** 修改按钮操作 */
  306. function handleUpdate(row) {
  307. // const id = row.id || ids.value;
  308. // proxy.$refs.workOrderRef.open(id);
  309. }
  310. /** 删除按钮操作 */
  311. function handleDelete(row) {
  312. const _ids = row.id || ids.value;
  313. proxy.$modal
  314. .confirm("是否确认删除选中的数据项?")
  315. .then(function () {
  316. return delWorkOrder(_ids);
  317. })
  318. .then(() => {
  319. getList();
  320. proxy.$modal.msgSuccess("删除成功!");
  321. })
  322. .catch(() => { });
  323. }
  324. /** 导出按钮操作 */
  325. function handleExport() {
  326. exportNoContract(queryParams.value);
  327. }
  328. function startDateChangeHandler(row, startDate) {
  329. if (startDate) {
  330. // console.log(startDate)
  331. row.endMonth = proxy
  332. .moment(startDate)
  333. .add(row.monthNum- 1, "M")
  334. .format("YYYY-MM-DD");
  335. } else row.endMonth = null;
  336. }
  337. function querySearchCompanyAsync(queryString, cb) {
  338. const query =
  339. queryString.length > 0
  340. ? {
  341. keyword: queryString,
  342. pageSize: 20,
  343. pageNum: 1,
  344. orderByColumn: "create_time",
  345. }
  346. : { pageSize: 20, pageNum: 1, orderByColumn: "create_time" };
  347. listCompany(query).then((res) => {
  348. cb(res.rows);
  349. });
  350. }
  351. function handleSelectCompany(item) {
  352. form.value.companyName = item.name;
  353. form.value.companyId = item.id;
  354. }
  355. function saveHandler() {
  356. if (form.value.companyId == null) {
  357. proxy.$modal.msgError("请选择公司");
  358. return;
  359. }
  360. if (form.value.remark == null || form.value.remark === "") {
  361. proxy.$modal.msgError("请输入备注");
  362. return;
  363. }
  364. if (form.value.id == null) {
  365. addWorkOrder(form.value).then((res) => {
  366. formCancel();
  367. getList();
  368. });
  369. }
  370. }
  371. function getTransactor(row) {
  372. if (row.entrusts != null && row.entrusts.length > 0) {
  373. const names = Array.from(new Set(row.entrusts.map((v) => v.toAccountName)));
  374. return names.join(",");
  375. } else {
  376. return row.serviceName;
  377. }
  378. }
  379. function showAddCompanyDialog() {
  380. addCompanyDialogRef.value.open();
  381. }
  382. function Upgrade() {
  383. fullscreenLoading.value = true;
  384. //这个是检查是否有未匹配工单
  385. checkMatchWorkOrder();
  386. //这个是完成升级调用的
  387. // const promise = Promise.resolve(completeUpgrade());
  388. // promise
  389. }
  390. function checkMatchWorkOrder() {
  391. const promise = checkWorkOrder();
  392. promise.then((res)=>{
  393. if(res.msg === "true"){
  394. fullscreenLoading.value = false;
  395. return Promise.reject("您尚未完成工单匹配,还有工单缺少合同,请先去补全合同");
  396. }else{
  397. fullscreenLoading.value = false;
  398. return ElMessageBox.confirm("升级后,您的账套将会切换成为标准版,您确定完成吗").then(()=>{
  399. fullscreenLoading.value = true;
  400. return completeUpgrade()
  401. }).catch((e)=>{
  402. return Promise.reject("取消升级");
  403. });
  404. }
  405. })
  406. .then((res) => {
  407. fullscreenLoading.value = false;
  408. ElMessageBox.alert(res.msg, '消息', {
  409. confirmButtonText: '确认',
  410. callback: (action) => {
  411. },
  412. })
  413. })
  414. .catch((e) => {
  415. fullscreenLoading.value = false;
  416. if(e !== "取消升级"){
  417. proxy.$alert(
  418. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  419. e +
  420. "</div>"
  421. ,
  422. {dangerouslyUseHTMLString: true}
  423. );
  424. }
  425. });
  426. }
  427. getList();
  428. </script>
  429. <style>
  430. .listbutton{
  431. display: flex;
  432. justify-content: space-between;
  433. }
  434. </style>