index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '新增合同',
  14. action: () => newContract(),
  15. },
  16. ]"
  17. @get-list="getList">
  18. <template #amount="{ item }">
  19. <div>
  20. <span style="padding-right: 4px">{{ item.currency }}</span>
  21. <span>{{ moneyFormat(item.amount, 2) }}</span>
  22. </div>
  23. </template>
  24. <template #claimAmount="{ item }">
  25. <div>
  26. <span style="padding-right: 4px">{{ item.currency }}</span>
  27. <span>{{ moneyFormat(item.claimAmount, 2) }}</span>
  28. </div>
  29. </template>
  30. <template #advanceRatio="{ item }">
  31. <div>
  32. <span>{{ item.advanceRatio }}%</span>
  33. </div>
  34. </template>
  35. </byTable>
  36. </div>
  37. <el-dialog title="服务记录" v-if="dialogVisible" v-model="dialogVisible" width="800" v-loading="loadingDialog">
  38. <div style="margin-bottom: 20px">
  39. <el-button type="primary" @click="clickAddRecord" plain>添加服务记录</el-button>
  40. </div>
  41. <el-timeline>
  42. <el-timeline-item v-for="(item, index) in recordList" :key="index" :timestamp="item.serviceTime" :hide-timestamp="true">
  43. <div>
  44. <div style="display: flex; justify-content: space-between; padding-bottom;: 20px">
  45. <span>{{ item.userName }}</span>
  46. <span>{{ item.serviceTime }}</span>
  47. </div>
  48. <div style="padding-bottom;: 20px">
  49. <div v-html="item.remark"></div>
  50. </div>
  51. <div style="padding-bottom;: 20px" v-if="item.fileList && item.fileList.length > 0">
  52. <div v-for="(file, index) in item.fileList" :key="index">
  53. <a style="color: #409eff; cursor: pointer" @click="openFile(file.fileUrl)">{{ file.fileName }}</a>
  54. </div>
  55. </div>
  56. </div>
  57. </el-timeline-item>
  58. </el-timeline>
  59. <div style="padding: 16px; text-align: center">
  60. <el-button @click="dialogVisible = false" size="large">关 闭</el-button>
  61. </div>
  62. </el-dialog>
  63. <el-dialog title="服务记录" v-if="openAddRecord" v-model="openAddRecord" width="700" v-loading="loadingRecord">
  64. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  65. <template #serviceTime>
  66. <div>
  67. <el-date-picker v-model="formData.data.serviceTime" type="datetime" placeholder="请选择服务时间" value-format="YYYY-MM-DD HH:mm:ss" />
  68. </div>
  69. </template>
  70. <template #remark>
  71. <div style="width: 100%">
  72. <Editor :value="formData.data.remark" @updateValue="updateContent" />
  73. </div>
  74. </template>
  75. <template #file>
  76. <div style="width: 100%">
  77. <el-upload
  78. v-model:fileList="fileList"
  79. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  80. :data="uploadData"
  81. multiple
  82. :before-upload="uploadFile"
  83. :on-preview="onPreviewFile">
  84. <el-button>选择</el-button>
  85. </el-upload>
  86. </div>
  87. </template>
  88. </byForm>
  89. <template #footer>
  90. <el-button @click="openAddRecord = false" size="large">取 消</el-button>
  91. <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
  92. </template>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script setup>
  97. import { computed, ref } from "vue";
  98. import byTable from "@/components/byTable/index";
  99. import { ElMessage, ElMessageBox } from "element-plus";
  100. import byForm from "@/components/byForm/index";
  101. import useUserStore from "@/store/modules/user";
  102. import Editor from "@/components/Editor/index.vue";
  103. import path from "path";
  104. const { proxy } = getCurrentInstance();
  105. const corporationList = ref([]);
  106. const customerList = ref([]);
  107. const userList = ref([]);
  108. const status = ref([
  109. {
  110. label: "审批中",
  111. value: 10,
  112. },
  113. {
  114. label: "驳回",
  115. value: 20,
  116. },
  117. {
  118. label: "审批通过",
  119. value: 30,
  120. },
  121. {
  122. label: "作废",
  123. value: 999,
  124. },
  125. ]);
  126. const serviceStatus = ref([
  127. {
  128. label: "服务中",
  129. value: 10,
  130. },
  131. {
  132. label: "已完结",
  133. value: 20,
  134. },
  135. ]);
  136. const sourceList = ref({
  137. data: [],
  138. pagination: {
  139. total: 0,
  140. pageNum: 1,
  141. pageSize: 10,
  142. keyword: "",
  143. status: "",
  144. serviceStatus: "",
  145. },
  146. });
  147. const loading = ref(false);
  148. const selectConfig = computed(() => {
  149. return [
  150. {
  151. label: "审批状态",
  152. prop: "status",
  153. data: status.value,
  154. },
  155. {
  156. label: "服务状态",
  157. prop: "serviceStatus",
  158. data: serviceStatus.value,
  159. },
  160. ];
  161. });
  162. const config = computed(() => {
  163. return [
  164. {
  165. attrs: {
  166. label: "归属公司",
  167. prop: "sellCorporationId",
  168. "min-width": 220,
  169. },
  170. render(type) {
  171. let text = "";
  172. if (corporationList.value && corporationList.value.length > 0) {
  173. let data = corporationList.value.filter((item) => item.value == type);
  174. if (data && data.length > 0) {
  175. text = data[0].label;
  176. }
  177. }
  178. return text;
  179. },
  180. },
  181. {
  182. attrs: {
  183. label: "合同编码",
  184. prop: "code",
  185. width: 180,
  186. },
  187. },
  188. {
  189. attrs: {
  190. label: "客户",
  191. prop: "buyCorporationId",
  192. "min-width": 220,
  193. },
  194. render(type) {
  195. let text = "";
  196. if (customerList.value && customerList.value.length > 0) {
  197. let data = customerList.value.filter((item) => item.value == type);
  198. if (data && data.length > 0) {
  199. text = data[0].label;
  200. }
  201. }
  202. return text;
  203. },
  204. },
  205. {
  206. attrs: {
  207. label: "版本号",
  208. prop: "version",
  209. width: 120,
  210. },
  211. },
  212. {
  213. attrs: {
  214. label: "合同金额",
  215. slot: "amount",
  216. width: 140,
  217. },
  218. },
  219. {
  220. attrs: {
  221. label: "已到账金额",
  222. slot: "claimAmount",
  223. width: 140,
  224. },
  225. },
  226. {
  227. attrs: {
  228. label: "业务员",
  229. prop: "userName",
  230. width: 140,
  231. },
  232. },
  233. {
  234. attrs: {
  235. label: "创建时间",
  236. prop: "createTime",
  237. width: 160,
  238. },
  239. },
  240. {
  241. attrs: {
  242. label: "审批状态",
  243. prop: "status",
  244. width: 140,
  245. },
  246. render(type) {
  247. let text = "";
  248. if (status.value && status.value.length > 0) {
  249. let data = status.value.filter((item) => item.value == type);
  250. if (data && data.length > 0) {
  251. text = data[0].label;
  252. }
  253. }
  254. return text;
  255. },
  256. },
  257. {
  258. attrs: {
  259. label: "到款状态",
  260. prop: "serviceStatus",
  261. width: 140,
  262. },
  263. render(type) {
  264. let text = "";
  265. if (serviceStatus.value && serviceStatus.value.length > 0) {
  266. let data = serviceStatus.value.filter((item) => item.value == type);
  267. if (data && data.length > 0) {
  268. text = data[0].label;
  269. }
  270. }
  271. return text;
  272. },
  273. },
  274. {
  275. attrs: {
  276. label: "操作",
  277. width: "140",
  278. align: "center",
  279. fixed: "right",
  280. },
  281. renderHTML(row) {
  282. return [
  283. {
  284. attrs: {
  285. label: "作废",
  286. type: "primary",
  287. text: true,
  288. },
  289. el: "button",
  290. click() {
  291. ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  292. confirmButtonText: "确定",
  293. cancelButtonText: "取消",
  294. type: "warning",
  295. }).then(() => {
  296. proxy
  297. .post("/serviceContract/cancel", {
  298. id: row.id,
  299. status: 88,
  300. })
  301. .then(() => {
  302. ElMessage({
  303. message: "作废成功",
  304. type: "success",
  305. });
  306. getList();
  307. });
  308. });
  309. },
  310. },
  311. {
  312. attrs: {
  313. label: "服务记录",
  314. type: "primary",
  315. text: true,
  316. },
  317. el: "button",
  318. click() {
  319. clickRecord(row);
  320. },
  321. },
  322. ];
  323. },
  324. },
  325. ];
  326. });
  327. const getDict = () => {
  328. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  329. corporationList.value = res.rows.map((item) => {
  330. return {
  331. ...item,
  332. label: item.name,
  333. value: item.id,
  334. };
  335. });
  336. });
  337. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  338. customerList.value = res.rows.map((item) => {
  339. return {
  340. ...item,
  341. label: item.name,
  342. value: item.id,
  343. };
  344. });
  345. });
  346. proxy.get("/tenantUser/list", { pageNum: 1, pageSize: 10000, tenantId: useUserStore().user.tenantId }).then((res) => {
  347. userList.value = res.rows.map((item) => {
  348. return {
  349. label: item.nickName,
  350. value: item.userId,
  351. };
  352. });
  353. });
  354. };
  355. const getList = async (req) => {
  356. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  357. loading.value = true;
  358. proxy.post("/serviceContract/page", sourceList.value.pagination).then((res) => {
  359. sourceList.value.data = res.rows;
  360. sourceList.value.pagination.total = res.total;
  361. setTimeout(() => {
  362. loading.value = false;
  363. }, 200);
  364. });
  365. };
  366. getDict();
  367. getList();
  368. const newContract = () => {
  369. proxy.$router.replace({
  370. path: "/platform_manage/process/processApproval",
  371. query: {
  372. flowKey: "service_contract_flow",
  373. flowName: "服务合同审批流程",
  374. },
  375. });
  376. };
  377. const submit = ref(null);
  378. const dialogVisible = ref(false);
  379. const loadingDialog = ref(false);
  380. const openAddRecord = ref(false);
  381. const recordList = ref([]);
  382. const getRecordList = () => {
  383. proxy.post("/serviceContractRecord/page", { serviceContractId: formData.data.serviceContractId }).then((res) => {
  384. if (res.rows && res.rows.length > 0) {
  385. recordList.value = res.rows;
  386. let fileIds = res.rows.map((item) => {
  387. return item.id;
  388. });
  389. proxy.post("/fileInfo/getList", { businessIdList: fileIds }).then((resFile) => {
  390. recordList.value = recordList.value.map((item) => {
  391. let fileData = [];
  392. if (resFile[item.id] && resFile[item.id].length > 0) {
  393. fileData = resFile[item.id];
  394. // .map((item) => {
  395. // return {
  396. // raw: item,
  397. // name: item.fileName,
  398. // url: item.fileUrl,
  399. // };
  400. // });
  401. }
  402. return {
  403. ...item,
  404. fileList: fileData,
  405. };
  406. });
  407. console.log(recordList.value);
  408. });
  409. } else {
  410. recordList.value = [];
  411. }
  412. loadingDialog.value = false;
  413. });
  414. };
  415. const clickRecord = (item) => {
  416. formData.data.serviceContractId = item.id;
  417. loadingDialog.value = true;
  418. dialogVisible.value = true;
  419. getRecordList();
  420. };
  421. const formOption = reactive({
  422. inline: true,
  423. labelWidth: 100,
  424. itemWidth: 100,
  425. rules: [],
  426. });
  427. const formData = reactive({
  428. data: {
  429. serviceContractId: "",
  430. remark: "",
  431. fileList: [],
  432. },
  433. });
  434. const formConfig = computed(() => {
  435. return [
  436. {
  437. label: "账户信息",
  438. },
  439. {
  440. type: "select",
  441. prop: "userId",
  442. label: "服务人员",
  443. data: userList.value,
  444. },
  445. {
  446. type: "slot",
  447. prop: "serviceTime",
  448. slotName: "serviceTime",
  449. label: "服务时间",
  450. },
  451. {
  452. type: "select",
  453. prop: "status",
  454. label: "服务状态",
  455. data: serviceStatus.value,
  456. },
  457. {
  458. type: "slot",
  459. prop: "remark",
  460. slotName: "remark",
  461. label: "服务记录",
  462. },
  463. {
  464. type: "slot",
  465. prop: "file",
  466. slotName: "file",
  467. label: "上传附件",
  468. },
  469. ];
  470. });
  471. const rules = ref({
  472. userId: [{ required: true, message: "请选择服务人员", trigger: "change" }],
  473. serviceTime: [{ required: true, message: "请选择服务时间", trigger: "change" }],
  474. status: [{ required: true, message: "请选择服务状态", trigger: "change" }],
  475. remark: [{ required: true, message: "请输入服务记录", trigger: "blur" }],
  476. });
  477. const fileList = ref([]);
  478. const uploadData = ref({});
  479. const loadingRecord = ref(false);
  480. const clickAddRecord = () => {
  481. formData.data = {
  482. serviceContractId: formData.data.serviceContractId,
  483. remark: "",
  484. fileList: [],
  485. };
  486. loadingRecord.value = false;
  487. openAddRecord.value = true;
  488. };
  489. const updateContent = (val) => {
  490. formData.data.remark = val;
  491. };
  492. const uploadFile = async (file) => {
  493. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  494. uploadData.value = res.uploadBody;
  495. file.id = res.id;
  496. file.fileName = res.fileName;
  497. file.fileUrl = res.fileUrl;
  498. return true;
  499. };
  500. const onPreviewFile = (file) => {
  501. window.open(file.raw.fileUrl, "_blank");
  502. };
  503. const submitForm = () => {
  504. submit.value.handleSubmit(() => {
  505. if (fileList.value && fileList.value.length > 0) {
  506. formData.data.fileList = fileList.value.map((item) => {
  507. return {
  508. id: item.raw.id,
  509. fileName: item.raw.fileName,
  510. fileUrl: item.raw.fileUrl,
  511. };
  512. });
  513. }
  514. loadingRecord.value = true;
  515. proxy.post("/serviceContractRecord/add", formData.data).then(
  516. () => {
  517. ElMessage({
  518. message: "添加成功",
  519. type: "success",
  520. });
  521. openAddRecord.value = false;
  522. getRecordList();
  523. },
  524. (err) => {
  525. console.log(err);
  526. loadingRecord.value = false;
  527. }
  528. );
  529. });
  530. };
  531. const openFile = (path) => {
  532. window.open(path, "_blank");
  533. };
  534. </script>
  535. <style lang="scss" scoped>
  536. .tenant {
  537. padding: 20px;
  538. }
  539. ::v-deep(.el-input-number .el-input__inner) {
  540. text-align: left;
  541. }
  542. </style>