detail.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="flex flex-col h-full">
  3. <div class="bg-white info flex-1 overflow-y-auto cellnormall">
  4. <van-cell title="合同所属部门">
  5. <template #default>
  6. <span>
  7. <TranslationComponent type="departmentName" :openId="infoData.departmentName" />
  8. </span>
  9. </template>
  10. </van-cell>
  11. <van-cell title="合同编号" :value="infoData.number" />
  12. <van-cell title="合同名称" :value="infoData.name" />
  13. <van-cell title="合同金额" :value="infoData.amounts">
  14. <template #default>
  15. <span class="text-[#FF8B32]" v-if="infoData.amounts">¥ {{ infoData.amounts }}</span>
  16. </template>
  17. </van-cell>
  18. <van-cell title="开票金额" :value="infoData.invoicedAmount">
  19. <template #default>
  20. <span class="text-[#FF8B32]" v-if="infoData.invoicedAmount">¥ {{ infoData.invoicedAmount }}</span>
  21. </template>
  22. </van-cell>
  23. <van-cell title="已回款金额" :value="infoData.payment">
  24. <template #default>
  25. <span class="text-[#FF8B32]" v-if="infoData.payment">¥ {{ infoData.payment }}</span>
  26. </template>
  27. </van-cell>
  28. <van-cell title="已回款进度" :value="infoData.payment">
  29. <template #default>
  30. {{ infoData.payment ? (100 * infoData.payment / infoData.amounts).toFixed(1) + '%' : '0%' }}
  31. </template>
  32. </van-cell>
  33. <van-cell title="计划开始时间" :value="infoData.startDate" />
  34. <van-cell title="计划结束时间" :value="infoData.endDate" />
  35. <van-cell title="下笔回款日期" :value="infoData.nextPaymentDate">
  36. <template #default>
  37. {{ infoData.nextPaymentDate ? infoData.nextPaymentDate : '-' }}
  38. </template>
  39. </van-cell>
  40. <van-cell title="下笔回款金额">
  41. <template #default>
  42. <span class="text-[#FF8B32]" v-if="infoData.nextPaymentAmount">¥ {{ infoData.
  43. nextPaymentAmount?.toFixed(2) }}</span>
  44. </template>
  45. </van-cell>
  46. <van-cell title="合同类型" :value="infoData.typeName" />
  47. <van-cell title="状态" :value="infoData.status">
  48. <template #default>
  49. <span :style="fixedFieldStatusArray[infoData.status].color">
  50. {{ fixedFieldStatusArray[infoData.status].label }}
  51. </span>
  52. </template>
  53. </van-cell>
  54. </div>
  55. <div class="bottomButton">
  56. <template v-if="infoData.status == 1">
  57. <van-button type="success" class="w-full block" @click="adoptOperation">通过合同</van-button>
  58. <van-button type="danger" class="w-full block" @click="rejectOperation">驳回合同</van-button>
  59. </template>
  60. <van-button type="default" class="w-full block" v-permission="[routingInformation.jurisdiction.edit]"
  61. @click="jumpEdit(infoData)">编辑合同</van-button>
  62. <van-button type="danger" class="w-full block" v-permission="[routingInformation.jurisdiction.delete]"
  63. @click="deleteRow()">删除合同</van-button>
  64. </div>
  65. <!-- 驳回弹窗 -->
  66. <van-dialog v-model:show="showDialog" :title="`驳回合同`" show-cancel-button @confirm="confirmTransfer"
  67. :before-close="dialogCloseBefo">
  68. <template #default>
  69. <van-field v-model.trim="dialogSelection" type="textarea" rows="3" label="驳回原因" placeholder="请输入驳回原因" />
  70. </template>
  71. </van-dialog>
  72. </div>
  73. </template>
  74. <script setup>
  75. import { ref, watch } from 'vue';
  76. import requests from "@common/requests";
  77. import { showConfirmDialog } from 'vant';
  78. import { useLifecycle } from '@hooks/useCommon.js';
  79. import { fixedFieldStatusArray } from '@/utility/defaultData.js';
  80. import { CONTRACT_APPROVED, OBTAIN_CONTRACT_DETAILS } from '@hooks/useApi'
  81. import useShowToast from '@hooks/useToast'
  82. import useInfoStore from '@store/useInfoStore'
  83. import useRouterStore from "@store/useRouterStore.js";
  84. import { routingInfos } from "@utility/generalVariables"
  85. import { resetListData, getListFieldKey } from '@components/common/formForm/formCorrespondenceProcessing'
  86. import useFixedData from "@store/useFixedData.js"
  87. const fixedData = useFixedData()
  88. const router = useRouterStore()
  89. const userInfo = useInfoStore()
  90. const { toastSuccess, toastLoading, toastFail, toastText, clearToast } = useShowToast()
  91. const props = defineProps({
  92. info: {
  93. type: Object,
  94. required: true,
  95. default: () => ({})
  96. }
  97. })
  98. const routingInformation = routingInfos['contract']
  99. const showDialog = ref(false);
  100. const showSelect = ref(false);
  101. const dialogSelection = ref({});
  102. watch(() => props.info, (newValue) => {
  103. processingData(newValue.id)
  104. })
  105. const infoData = ref(props.info);
  106. const timeout = ref(null);
  107. function adoptOperation() {
  108. const { name = '', id } = infoData.value
  109. showConfirmDialog({
  110. title: `合同通过`,
  111. message: `确认审核通过吗?,通过后合同基本信息无法修改`,
  112. }).then(() => {
  113. requests.post(CONTRACT_APPROVED, { id, status: 0 }).then((res) => {
  114. toastSuccess('操作成功')
  115. processingData(id)
  116. }).catch((err) => {
  117. toastFail(err.msg ? err.msg : '操作失败')
  118. })
  119. })
  120. }
  121. function rejectOperation() {
  122. dialogSelection.value = ''
  123. showDialog.value = true
  124. }
  125. function confirmTransfer() {
  126. const { name = '', id } = infoData.value
  127. if (!dialogSelection.value) {
  128. return toastText('请输入驳回原因')
  129. }
  130. showConfirmDialog({
  131. title: `合同驳回`,
  132. message: `确认驳回吗?,驳回后合同基本信息无法修改`,
  133. }).then(() => {
  134. requests.post(CONTRACT_APPROVED, { id, status: 2, msg: dialogSelection.value }).then((res) => {
  135. toastSuccess('操作成功')
  136. showDialog.value = false
  137. processingData(id)
  138. })
  139. })
  140. }
  141. function dialogCloseBefo(val) {
  142. if (val == 'confirm' && showDialog.value) {
  143. return false
  144. }
  145. return true
  146. }
  147. function deleteRow() {
  148. const { name = '', searchFiled = {}, deteleFiled = '' } = routingInformation
  149. const row = props.info
  150. const foemVal = { [routingInformation.key == 'tasks' ? 'taskIds' : 'id']: row.id }
  151. showConfirmDialog({
  152. title: `删除${name}`,
  153. message: `确定删除【${row[searchFiled?.search]}】${name}吗?`,
  154. }).then(() => {
  155. requests.post(deteleFiled, { ...foemVal }).then((res) => {
  156. toastSuccess('删除成功')
  157. router.navigateBack({
  158. success: () => {
  159. router.emit('moduleListDetailParameter', {
  160. row: JSON.stringify(routingInformation)
  161. })
  162. }
  163. })
  164. }).catch((err) => {
  165. toastFail(err.msg ? err.msg : '删除失败')
  166. })
  167. })
  168. }
  169. function jumpEdit(row) {
  170. const formJson = fixedData.formJson[routingInformation.key] || []
  171. const formList = resetListData(formJson?.list)
  172. const filedObj = getListFieldKey(formList, infoData.value)
  173. const formVal = { ...filedObj, id: props.info.id, departmentId: row.departmentId, departmentName: row.departmentName }
  174. router.navigateTo({
  175. pathName: 'addEditor',
  176. success: () => {
  177. router.emit('addEditorParameter', {
  178. routerInfo: JSON.stringify(routingInformation),
  179. filedValue: JSON.stringify(formVal)
  180. })
  181. }
  182. })
  183. }
  184. function getDetails(id) {
  185. requests.post(OBTAIN_CONTRACT_DETAILS, { id }).then((res) => {
  186. infoData.value = res.data || {}
  187. }).finally(() => {
  188. setTimeout(() => {
  189. clearToast()
  190. }, 200)
  191. })
  192. }
  193. function processingData(id) {
  194. clearTimeout(timeout.value);
  195. toastLoading('加载中...', 0)
  196. timeout.value = setTimeout(() => {
  197. getDetails(id)
  198. }, 100);
  199. }
  200. useLifecycle({
  201. init: () => {
  202. processingData(props.info.id)
  203. },
  204. load: () => {
  205. processingData(props.info.id)
  206. },
  207. unload: () => {
  208. clearTimeout(timeout.value)
  209. }
  210. });
  211. </script>
  212. <style lang='scss' scoped>
  213. .bottomButton {
  214. margin: 0 14px;
  215. padding-bottom: 30px;
  216. :deep(.van-button) {
  217. margin-bottom: 20px;
  218. }
  219. }
  220. .info {
  221. margin: 8px 14px 30px 14px;
  222. padding: 14px;
  223. }
  224. </style>