info3.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <wt-card title="相关合同" class="mt-10">
  3. <div
  4. class="full-width text-right main-color pointer"
  5. style="margin-top: -10px"
  6. @click="moreContract"
  7. >
  8. 查看更多>>
  9. </div>
  10. <div class="flex flex-justify-start full-width mt-15">
  11. <avue-crud
  12. :option="option"
  13. :data="data"
  14. ref="crud"
  15. v-model="form"
  16. :before-open="beforeOpen"
  17. @row-del="rowDel"
  18. @refresh-change="refreshChange"
  19. >
  20. <template #menu-left>
  21. <div class="flex flex-center">
  22. <filepicker
  23. v-if="form.can_update"
  24. btn-text="新增合同"
  25. :project-id="projectId"
  26. @submit="selection"
  27. />
  28. </div>
  29. </template>
  30. </avue-crud>
  31. </div>
  32. </wt-card>
  33. </template>
  34. <script>
  35. import wtCard from '@/components/wt-card/index.vue'
  36. import filepicker from '@/components/filepicker/index.vue'
  37. export default {
  38. name: 'info3',
  39. components: {
  40. wtCard,
  41. filepicker
  42. },
  43. props: {
  44. projectId: {
  45. required: true,
  46. type: String,
  47. default: ''
  48. },
  49. stageId: {
  50. required: true,
  51. type: String,
  52. default: ''
  53. }
  54. },
  55. watch: {
  56. projectId: {
  57. handler(val) {
  58. if (val.length > 0) {
  59. this.onLoad()
  60. }
  61. },
  62. immediate: true
  63. },
  64. stageId: {
  65. handler(val) {
  66. if (val.length > 0) {
  67. this.onLoad()
  68. }
  69. },
  70. immediate: true
  71. }
  72. },
  73. data() {
  74. return {
  75. form: {},
  76. data: [],
  77. option: {
  78. align: 'center',
  79. menuAlign: 'center',
  80. menuWidth: 180,
  81. size: 'mini',
  82. addBtn: false,
  83. editBtn: false,
  84. viewBtn: true,
  85. delBtn: true,
  86. columnBtn: false,
  87. labelWidth: 140,
  88. border: true,
  89. column: [
  90. {
  91. label: '合同名称',
  92. prop: 'title',
  93. fixed: true
  94. },
  95. {
  96. label: '合同金额',
  97. prop: 'amount',
  98. width: 180
  99. },
  100. {
  101. label: '业务联系人',
  102. prop: 'contacts',
  103. width: 120
  104. },
  105. {
  106. label: '合同乙方',
  107. prop: 'partyB'
  108. }
  109. ]
  110. },
  111. page: {
  112. size: 10,
  113. current: 1
  114. }
  115. }
  116. },
  117. methods: {
  118. onLoad() {
  119. this.loading = true
  120. const data = Object.assign({
  121. projectId: this.projectId,
  122. stageId: this.stageId
  123. })
  124. this.$api.contract
  125. .contractList(Object.assign(this.page, data))
  126. .then(res => {
  127. this.data = res.data.records.map(ele => {
  128. if (ele.contractsStatus === -1) {
  129. ele.contractsStatus = ''
  130. }
  131. if (ele.type === -1) {
  132. ele.type = ''
  133. }
  134. return ele
  135. })
  136. this.page.total = res.data.total
  137. })
  138. .finally(() => {
  139. this.loading = false
  140. })
  141. },
  142. beforeOpen(done, type) {
  143. if (type === 'view') {
  144. const data = this.$router.resolve({
  145. path: '/contract/detail',
  146. query: { id: this.form.id }
  147. })
  148. window.open(data.href, '_blank')
  149. }
  150. },
  151. rowDel(row, index, done) {
  152. this.$confirm('确定将选择数据删除?', {
  153. type: 'warning'
  154. }).then(res => {
  155. console.log(res)
  156. if (res === 'confirm') {
  157. this.$api.contract.contractRemove({ ids: row.id }).then(res => {
  158. if (res.code === 200) {
  159. this.$message.success(res.msg)
  160. this.onLoad()
  161. } else {
  162. this.$message.error(res.msg)
  163. }
  164. })
  165. }
  166. })
  167. },
  168. currentChange(currentPage) {
  169. this.page.current = currentPage
  170. },
  171. sizeChange(pageSize) {
  172. this.page.size = pageSize
  173. },
  174. refreshChange() {
  175. this.onLoad()
  176. },
  177. selection(list) {
  178. const tmps = list.map(ele => {
  179. return {
  180. fileId: ele.id,
  181. projectId: ele.projectId,
  182. stageId: this.stageId,
  183. title: ele.title
  184. }
  185. })
  186. this.$api.contract.linkContract(tmps).then(res => {
  187. if (res.code === 200) {
  188. this.refreshChange()
  189. }
  190. })
  191. },
  192. moreContract() {
  193. this.$router.push({
  194. path: '/contract',
  195. query: { id: this.projectId }
  196. })
  197. }
  198. }
  199. }
  200. </script>
  201. <style scoped></style>