supplier-account-add-or-update.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div>
  3. <div class="my-title">{{ !id ? '新增': formDisable ? '详情' : '修改' }}</div>
  4. <div style="margin-top: 20px"></div>
  5. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" :disabled="formDisable" label-width="auto">
  6. <el-row class="my-row">
  7. <el-col :span="8">
  8. <el-form-item label="账款编码" prop="customerAccountCode">
  9. <el-input v-model="dataForm.customerAccountCode" :disabled="true" placeholder="系统自动生成"></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="8" >
  13. <el-form-item label="账款类型" prop="type">
  14. <el-select v-model="dataForm.type" filterable placeholder="请选择">
  15. <el-option
  16. v-for="item in typeState"
  17. :key="item.code"
  18. :label="item.value"
  19. :value="item.code">
  20. </el-option>
  21. </el-select>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="8" >
  25. <el-form-item label="合同号" prop="contractNumber">
  26. <el-input v-model="dataForm.contractNumber" placeholder=""></el-input>
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-row class="my-row">
  31. <el-col :span="8">
  32. <el-form-item label="收付款时间" prop="receivedPaidTime">
  33. <el-date-picker
  34. v-model="dataForm.receivedPaidTime"
  35. type="date"
  36. value-format="yyyy-MM-dd">
  37. </el-date-picker>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="8" >
  41. <el-form-item label="币种" prop="currency">
  42. <el-select v-model="dataForm.currency" filterable placeholder="请选择">
  43. <el-option
  44. v-for="item in currencyType"
  45. :key="item.code"
  46. :label="item.value"
  47. :value="item.code">
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="8" >
  53. <el-form-item label="收付款金额" prop="receivedPaidAmount">
  54. <el-input v-model="dataForm.receivedPaidAmount" placeholder=""></el-input>
  55. </el-form-item>
  56. </el-col>
  57. </el-row>
  58. <el-row class="my-row">
  59. <el-col :span="15">
  60. <el-form-item label="备注说明" prop="notes">
  61. <el-input type="textarea"
  62. v-model="dataForm.notes"
  63. :rows="4"
  64. maxlength="300"
  65. show-word-limit
  66. placeholder="备注说明"></el-input>
  67. </el-form-item>
  68. </el-col>
  69. </el-row>
  70. <el-row class="my-row">
  71. <upload-component :title="'附件'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
  72. </el-row>
  73. </el-form>
  74. <span slot="footer" class="dialog-footer">
  75. <el-button @click="onChose">取消</el-button>
  76. <el-button v-if="!formDisable" type="primary" @click="dataFormSubmit()">确定</el-button>
  77. </span>
  78. </div>
  79. </template>
  80. <script>
  81. import uploadComponent from '../common/upload-component'
  82. export default {
  83. name: 'supplier-account-add-or-update',
  84. components: {
  85. uploadComponent
  86. },
  87. data () {
  88. return {
  89. visible: false,
  90. formDisable: false,
  91. dataList: [],
  92. fileList: [],
  93. id: 0,
  94. dataForm: {},
  95. optionsType: [],
  96. optionsApplier: [],
  97. materialDetails: [],
  98. optionsCus: [], // 客户下拉列表
  99. customerInfo: {},
  100. customerVisible: false,
  101. customerLoading: false,
  102. totalAmount: 0,
  103. dataRule: {
  104. type: [{ required: true, message: '账款类型不能为空', trigger: 'blur' }],
  105. contractNumber: [{ required: true, message: '合同号不能为空', trigger: 'blur' }],
  106. receivedPaidTime: [{ required: true, message: '收付款时间不能为空', trigger: 'blur' }],
  107. receivedPaidAmount: [{ required: true, message: '收付款金额不能为空', trigger: 'blur' }],
  108. currency: [{ required: true, message: '币种不能为空', trigger: 'blur' }]
  109. },
  110. typeState: [ // 账款类别映射关系
  111. {
  112. code: '1',
  113. value: '采购付款'
  114. },
  115. {
  116. code: '2',
  117. value: '采购退款'
  118. }
  119. ],
  120. currencyType: [ // 币种映射关系
  121. {
  122. code: '1',
  123. value: '人民币'
  124. }
  125. ]
  126. }
  127. },
  128. watch: {
  129. },
  130. methods: {
  131. onChose () {
  132. console.log(5555)
  133. this.$emit('onChose')
  134. },
  135. async init (id, supplierAccount, supplierId, formDisable) {
  136. this.visible = true
  137. this.id = id || 0
  138. this.formDisable = formDisable
  139. this.fileList = []
  140. if (id && supplierAccount) {
  141. this.dataForm = {
  142. supplierAccountId: id,
  143. supplierAccountCode: supplierAccount.supplierAccountCode,
  144. type: supplierAccount.type,
  145. contractNumber: supplierAccount.contractNumber,
  146. receivedPaidTime: supplierAccount.receivedPaidTime,
  147. currency: supplierAccount.currency,
  148. receivedPaidAmount: supplierAccount.receivedPaidAmount,
  149. notes: supplierAccount.notes
  150. }
  151. supplierAccount.attachList && supplierAccount.attachList.forEach((item) => {
  152. this.fileList.push({
  153. name: item.fileName,
  154. url: item.url,
  155. id: item.url
  156. })
  157. })
  158. }
  159. this.dataForm.supplierId = supplierId
  160. // await getCustomer().then(({data}) => {
  161. // if (data && data.code === '200') {
  162. // this.optionsCus = data.data
  163. // }
  164. // })
  165. // if (!id) return
  166. // await getSaleInvoiceDetail(this.id).then(({data}) => {
  167. // if (data && data.code === '200') {
  168. // this.dataForm = data.data
  169. // // 文件列表
  170. // this.fileList = []
  171. // if (data.data.attachList) {
  172. // data.data.attachList.forEach((item) => {
  173. // this.fileList.push({
  174. // name: item.fileName,
  175. // url: item.url,
  176. // id: item.url
  177. // })
  178. // })
  179. // }
  180. // }
  181. // })
  182. },
  183. validateField (type) {
  184. this.$refs.dataForm.validateField(type)
  185. },
  186. // 表单提交
  187. dataFormSubmit () {
  188. this.$refs['dataForm'].validate((valid) => {
  189. if (valid) {
  190. // 添加附件
  191. let fList = this.fileList
  192. if (fList.length > 0) {
  193. this.dataForm.attachList = []
  194. for (let i = 0; i < fList.length; i++) {
  195. this.dataForm.attachList.push({
  196. fileName: fList[i].name,
  197. url: fList[i].url
  198. })
  199. }
  200. } else {
  201. this.$message.error('请上传文件')
  202. return
  203. }
  204. // let finSalesInvoice = {finSalesInvoice: this.dataForm}
  205. this.$http({
  206. url: !this.id ? this.$http.adornUrl(`/biz-service/finance/supplier/account/save`) : this.$http.adornUrl(`/biz-service/finance/supplier/account/update`),
  207. method: 'post',
  208. data: this.$http.adornData(this.dataForm)
  209. }).then(({data}) => {
  210. if (data && data.code === '200') {
  211. this.$message({
  212. message: '操作成功',
  213. type: 'success',
  214. duration: 1500,
  215. onClose: () => {
  216. this.onChose()
  217. this.$emit('refreshDataList')
  218. }
  219. })
  220. } else {
  221. this.$message.error(data.msg)
  222. }
  223. })
  224. }
  225. })
  226. },
  227. uploadSuccess (fileList) {
  228. this.fileList = fileList
  229. }
  230. }
  231. }
  232. </script>
  233. <style scoped>
  234. </style>