info2.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div>
  3. <div class="padding top flex flex-center flex-justify-between">
  4. <span>台账信息</span>
  5. </div>
  6. <div class="ml-20 mr-20 mt-20">
  7. <avue-crud
  8. :option="option"
  9. :data="data"
  10. ref="crud"
  11. v-model="form"
  12. :before-open="beforeOpen"
  13. @row-del="rowDel"
  14. @row-save="handleRowSave"
  15. @row-update="rowUpdate"
  16. @on-load="onLoad"
  17. >
  18. <template #fileIds-form="{ row, type }">
  19. <div v-if="type === 'view'">
  20. <div
  21. v-for="i in form.accountInformationFileList"
  22. :key="i.id"
  23. class="pointer"
  24. @click="previewFile(i)"
  25. >
  26. {{ i.title }}
  27. <el-button text type="primary" plain>查看</el-button>
  28. </div>
  29. </div>
  30. <div v-if="type === 'edit'">
  31. <div
  32. v-if="
  33. form.accountInformationFileList &&
  34. form.accountInformationFileList.length === 0
  35. "
  36. >
  37. <uploads :max="9" @success="uploadSucc" :auto="true" />
  38. <div>
  39. <div v-for="item in fileList" :key="item.id">
  40. {{ item.originalFileName }}
  41. </div>
  42. </div>
  43. </div>
  44. <div
  45. v-for="i in form.accountInformationFileList"
  46. :key="i.id"
  47. class="pointer"
  48. @click="removeFile(i)"
  49. >
  50. {{ i.title }}
  51. <el-button text type="primary" plain>删除</el-button>
  52. </div>
  53. </div>
  54. <div v-else>
  55. <uploads :max="9" @success="uploadSucc" :auto="true" />
  56. <div>
  57. <div v-for="item in fileList" :key="item.id">
  58. {{ item.originalFileName }}
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. </avue-crud>
  64. </div>
  65. <el-image-viewer
  66. v-if="showImage"
  67. :url-list="preList"
  68. @close="showImage = false"
  69. />
  70. </div>
  71. </template>
  72. <script>
  73. import uploads from '../../../components/uploads.vue'
  74. import api from '@/api/index.js'
  75. export default {
  76. name: 'info',
  77. components: { uploads },
  78. data() {
  79. return {
  80. id: '',
  81. showImage: false,
  82. preList: [],
  83. show: false,
  84. fileList: [],
  85. form: {},
  86. data: [],
  87. option: {
  88. align: 'center',
  89. menuAlign: 'center',
  90. menuWidth: 250,
  91. height: 480,
  92. size: 'mini',
  93. addBtn: true,
  94. editBtn: true,
  95. editBtnText: '支付凭证',
  96. viewBtn: true,
  97. delBtn: true,
  98. refreshBtn: false,
  99. columnBtn: false,
  100. labelWidth: 140,
  101. border: true,
  102. column: [
  103. {
  104. label: '名称',
  105. prop: 'name',
  106. rules: [
  107. {
  108. required: true,
  109. message: '请输入台账名称',
  110. trigger: 'blur'
  111. }
  112. ]
  113. },
  114. {
  115. label: '款项类别',
  116. prop: 'dictKey',
  117. type: 'select',
  118. dicUrl: '/api/blade-system/dict-biz/dictionary?code=payment-type',
  119. props: {
  120. label: 'dictValue',
  121. value: 'dictKey'
  122. },
  123. rules: [
  124. {
  125. required: true,
  126. message: '请选择款项类别',
  127. trigger: 'blur'
  128. }
  129. ]
  130. },
  131. {
  132. label: '支付金额',
  133. prop: 'payment',
  134. type: 'number',
  135. rules: [
  136. {
  137. required: true,
  138. message: '请输入支付金额',
  139. trigger: 'blur'
  140. }
  141. ]
  142. },
  143. {
  144. label: '付款人',
  145. prop: 'payer',
  146. hide: true,
  147. rules: [
  148. {
  149. required: true,
  150. message: '请填写付款人',
  151. trigger: 'blur'
  152. }
  153. ]
  154. },
  155. {
  156. label: '收款人',
  157. prop: 'payee',
  158. hide: true,
  159. rules: [
  160. {
  161. required: true,
  162. message: '请填写收款人',
  163. trigger: 'blur'
  164. }
  165. ]
  166. },
  167. {
  168. label: '支付账户',
  169. prop: 'paymentAccount',
  170. hide: true,
  171. rules: [
  172. {
  173. required: true,
  174. message: '请填写支付账户',
  175. trigger: 'blur'
  176. }
  177. ]
  178. },
  179. {
  180. label: '支付凭证',
  181. prop: 'fileIds',
  182. hide: true,
  183. formSlot: true,
  184. rules: [
  185. {
  186. required: true,
  187. message: '请上传支付凭证',
  188. trigger: 'blur'
  189. }
  190. ]
  191. },
  192. {
  193. label: '付款时间',
  194. prop: 'paymentTime',
  195. type: 'datetime',
  196. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  197. format: 'YYYY-MM-DD HH:mm:ss',
  198. rules: [
  199. {
  200. required: true,
  201. message: '请选择付款时间',
  202. trigger: 'blur'
  203. }
  204. ]
  205. },
  206. {
  207. label: '备注',
  208. prop: 'remark',
  209. type: 'textarea',
  210. span: 24,
  211. rows: 1
  212. }
  213. ]
  214. }
  215. }
  216. },
  217. created() {
  218. this.id = this.$route.query.id
  219. },
  220. methods: {
  221. onLoad() {
  222. this.$api.contract.ledgerList({ contractId: this.id }).then(res => {
  223. if (res.code === 200) {
  224. this.data = res.data
  225. }
  226. })
  227. },
  228. beforeOpen(done, type) {
  229. if (type === 'view') {
  230. done()
  231. } else if (type === 'edit') {
  232. done()
  233. } else {
  234. done()
  235. }
  236. },
  237. previewFile(item) {
  238. if (api.offices.includes(item.suffix)) {
  239. const routeData = this.$router.resolve({
  240. path: '/home/file_detail',
  241. query: { id: item.fileId }
  242. })
  243. window.open(routeData.href, '_blank')
  244. } else {
  245. this.preList.length = 0
  246. this.preList.push(item.url)
  247. this.showImage = true
  248. }
  249. },
  250. removeFile(item) {
  251. this.$confirm('请确认是否删除该条支付凭证!', {
  252. type: 'warning'
  253. }).then(res => {
  254. if (res === 'confirm') {
  255. this.$api.contract.voucherDel({ ids: item.id }).then(res => {
  256. if (res.code === 200) {
  257. this.form.accountInformationFileList = item.filter(
  258. sub => sub.id !== item
  259. )
  260. }
  261. })
  262. }
  263. })
  264. },
  265. rowUpdate(row, index, done, loading) {
  266. loading()
  267. const data = Object.assign(row, { contractId: this.id })
  268. this.$api.contract.ledgerUpdate(data).then(
  269. res => {
  270. if (res.code === 200) {
  271. this.$message.success(res.msg)
  272. } else {
  273. this.$message.error(res.msg)
  274. }
  275. done(row)
  276. this.onLoad()
  277. },
  278. error => {
  279. window.console.log(error)
  280. loading()
  281. }
  282. )
  283. },
  284. handleRowSave(row, done, loading) {
  285. loading()
  286. const data = Object.assign(row, { contractId: this.id })
  287. this.$confirm(
  288. '请检查并确认所填写内容是否正确,系统将会根据填写内容,计算合同付款等相关数据!',
  289. {
  290. type: 'warning'
  291. }
  292. ).then(res => {
  293. if (res === 'confirm') {
  294. this.$api.contract.ledgerAdd(data).then(res => {
  295. if (res.code === 200) {
  296. done(row)
  297. this.onLoad()
  298. }
  299. })
  300. }
  301. })
  302. },
  303. rowDel(row, index, done) {
  304. this.$confirm('确认删除该内容?', {
  305. type: 'warning'
  306. }).then(res => {
  307. if (res === 'confirm') {
  308. this.$api.contract.remove({ ids: row.id }).then(res => {
  309. if (res.code === 200) {
  310. this.$message.success(res.msg)
  311. this.onLoad()
  312. done(row)
  313. } else {
  314. this.$message.error(res.msg)
  315. }
  316. })
  317. }
  318. console.log(res)
  319. })
  320. },
  321. uploadSucc(res) {
  322. const tmp = res.fileList.map(ele => {
  323. return ele.response.data
  324. })
  325. this.fileList = this.fileList.concat(tmp)
  326. this.form.fileIds = this.fileList.map(ele => ele.id).join(',')
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss" scoped>
  332. .top {
  333. height: 35px;
  334. border-radius: var(--el-card-border-radius);
  335. background-color: #f5f5f3;
  336. }
  337. </style>