customerBillingInfoedit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="app-container">
  3. <el-row class="title-style">
  4. <el-col :span="12">
  5. <h2 class="bg-left title">客户账单</h2>
  6. </el-col>
  7. <el-col :span="12" class="bg-right">
  8. <el-button class="bg-bottom" type="primary" size="small" @click="returnsales()">返回</el-button>
  9. <el-button type="primary" size="small" @click="editData">提交</el-button>
  10. </el-col>
  11. </el-row>
  12. <el-form
  13. ref="dataForm"
  14. :rules="rules"
  15. :model="dataForm"
  16. status-icon
  17. label-position="left"
  18. label-width="200px"
  19. class="position"
  20. >
  21. <div class="small-title" style="font-size: 16px">基本信息</div>
  22. <div class="ws-info-table">
  23. <el-form-item label="id" prop="id" hidden>
  24. <el-input v-model="dataForm.id"/>
  25. </el-form-item>
  26. <el-form-item label="编号:" prop="payNo" style="margin-right:50px">
  27. <el-input v-model="dataForm.payNo" class="input-width" disabled="true"/>
  28. </el-form-item>
  29. <el-form-item label="客户:" prop="customer" style="margin-right:50px">
  30. <el-input v-model="dataForm.customer" class="input-width" disabled="true"/>
  31. </el-form-item>
  32. <el-form-item label="单据类型:" prop="businessType" style="margin-right:50px">
  33. <el-select v-model="dataForm.businessType" placeholder="请选择单据类型" class="input-width" disabled="true">
  34. <el-option
  35. v-for="item in djList"
  36. :label="item.label"
  37. :value="item.value"
  38. :key="item.value"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="结账日期" prop="closingDate" style="margin-right:50px">
  43. <el-date-picker
  44. v-model="dataForm.closingDate"
  45. type="date"
  46. value-format="yyyy-MM-dd"
  47. style="width:200px"
  48. />
  49. </el-form-item>
  50. <el-form-item label="应付金额:" prop="amountIng" style="margin-right:50px">
  51. <el-input v-model="dataForm.amountIng" class="input-width"/>
  52. </el-form-item>
  53. <el-form-item label="已付金额:" prop="amountPaid" style="margin-right:50px">
  54. <el-input v-model="dataForm.amountPaid" class="input-width"/>
  55. </el-form-item>
  56. <el-form-item label="未付金额:" prop="unpaidAmount" style="margin-right:50px">
  57. <el-input v-model="dataForm.unpaidAmount" class="input-width"/>
  58. </el-form-item>
  59. <el-form-item label="备注1:" prop="remarks" style="margin-right:50px">
  60. <el-input v-model="dataForm.remarks" class="input-width"/>
  61. </el-form-item>
  62. <el-form-item label="备注2:" prop="remark" style="margin-right:50px">
  63. <el-input v-model="dataForm.remark" class="input-width"/>
  64. </el-form-item>
  65. <el-form-item label="状态:" prop="status" style="margin-right:50px">
  66. <el-select v-model="dataForm.status" placeholder="请选择收款状态" class="input-width">
  67. <el-option
  68. v-for="item in skList"
  69. :label="item.label"
  70. :value="item.value"
  71. :key="item.value"
  72. />
  73. </el-select>
  74. </el-form-item>
  75. </div>
  76. <div class="small-title" style="font-size: 16px">详情</div>
  77. <el-button style="margin-bottom:20px" @click="addDetail">添加</el-button>
  78. <el-table
  79. v-loading="listLoading"
  80. :data="list"
  81. :summary-method="getSummaries"
  82. size="small"
  83. element-loading-text="正在查询中。。。"
  84. border
  85. fit
  86. highlight-current-row
  87. show-summary
  88. @selection-change="handleSelectionChange"
  89. >
  90. <el-table-column :selectable="selectInit" type="selection" style="width:30px" />
  91. <el-table-column type="index" label="序号">
  92. <template scope="scope">
  93. <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
  94. <span v-else>{{ scope.$index + 1 }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column align="center" label="柜号" prop="cabinetNo">
  98. <template slot-scope="scope">
  99. <el-input v-model="scope.row.cabinetNo" />
  100. </template>
  101. </el-table-column>
  102. <el-table-column align="center" label="到港日期" prop="arrivalDate" width="170px">
  103. <template slot-scope="scope">
  104. <el-date-picker
  105. v-model="scope.row.arrivalDate"
  106. type="date"
  107. value-format="yyyy-MM-dd"
  108. style="width:140px"
  109. />
  110. </template>
  111. </el-table-column>
  112. <el-table-column align="center" label="送货地点" prop="deliveryPlace">
  113. <template slot-scope="scope">
  114. <el-input v-model="scope.row.deliveryPlace" />
  115. </template>
  116. </el-table-column>
  117. <el-table-column align="center" label="产品" prop="product">
  118. <template slot-scope="scope">
  119. <el-input v-model="scope.row.product" />
  120. </template>
  121. </el-table-column>
  122. <el-table-column align="center" label="重量" prop="weight">
  123. <template slot-scope="scope">
  124. <el-input v-model="scope.row.weight" />
  125. </template>
  126. </el-table-column>
  127. <el-table-column align="center" label="清关费" prop="clearanceFee">
  128. <template slot-scope="scope">
  129. <el-input v-model="scope.row.clearanceFee" />
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" label="清关成本" prop="clearanceCost">
  133. <template slot-scope="scope">
  134. <el-input v-model="scope.row.clearanceCost" />
  135. </template>
  136. </el-table-column>
  137. <el-table-column align="center" label="卡车" prop="truck">
  138. <template slot-scope="scope">
  139. <el-input v-model="scope.row.truck" />
  140. </template>
  141. </el-table-column>
  142. <el-table-column align="center" label="卡车成本" prop="truckCost">
  143. <template slot-scope="scope">
  144. <el-input v-model="scope.row.truckCost" />
  145. </template>
  146. </el-table-column>
  147. <el-table-column align="center" label="其他费用" prop="otherExpenses">
  148. <template slot-scope="scope">
  149. <el-input v-model="scope.row.otherExpenses" />
  150. </template>
  151. </el-table-column>
  152. <el-table-column align="center" label="其他成本" prop="otherCost">
  153. <template slot-scope="scope">
  154. <el-input v-model="scope.row.otherCost" />
  155. </template>
  156. </el-table-column>
  157. <el-table-column align="center" label="应付金额" prop="pricePayable">
  158. <template slot-scope="scope">
  159. <el-input v-model="scope.row.pricePayable" />
  160. </template>
  161. </el-table-column>
  162. <el-table-column align="center" label="成本价格" prop="cost">
  163. <template slot-scope="scope">
  164. <el-input v-model="scope.row.cost" />
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="center" label="备注1" prop="remarks">
  168. <template slot-scope="scope">
  169. <el-input v-model="scope.row.remarks" />
  170. </template>
  171. </el-table-column>
  172. <!-- <el-table-column align="center" label="备注2" prop="remark">
  173. <template slot-scope="scope">
  174. <el-input v-model="scope.row.remark" />
  175. </template>
  176. </el-table-column>-->
  177. <!-- <el-table-column align="center" label="状态" prop="status">
  178. <template slot-scope="scope">
  179. <el-input v-model="scope.row.status" />
  180. </template>
  181. </el-table-column>-->
  182. <el-table-column align="center" label="操作" class-name="small-padding fixed-width">
  183. <template slot-scope="scope">
  184. <el-button type="danger" size="mini" @click.native.prevent="deleteRow(scope.$index, list)">删除</el-button>
  185. </template>
  186. </el-table-column>
  187. </el-table>
  188. </el-form>
  189. </div>
  190. </template>
  191. <script>
  192. import {
  193. listCustomerBillingInfo,
  194. createCustomerBillingInfo,
  195. editCustomerBillingInfo,
  196. updateCustomerBillingInfo,
  197. deleteCustomerBillingInfo
  198. } from '@/api/customerBillingInfo'
  199. import { listCustomerBillingDetail } from '@/api/customerBillingDetail'
  200. import Pagination from '@/components/Pagination'
  201. export default {
  202. name: 'CustomerBillingInfo',
  203. components: { Pagination },
  204. data() {
  205. return {
  206. djList: [
  207. {
  208. value: '1',
  209. label: '正常单据'
  210. },
  211. {
  212. value: '2',
  213. label: '结转单据'
  214. }
  215. ],
  216. skList: [
  217. {
  218. value: 1,
  219. label: '未收款'
  220. },
  221. {
  222. value: 2,
  223. label: '部分收款'
  224. },
  225. {
  226. value: 3,
  227. label: '已收款'
  228. }
  229. ],
  230. billDetailList: [
  231. {
  232. payNo: '11',
  233. businessType: '1',
  234. closingDate: '1',
  235. amountPaid: '1',
  236. unpaidAmount: '1',
  237. remarks: '1',
  238. remark: '1',
  239. status: '1'
  240. }
  241. ],
  242. list: null,
  243. total: 0,
  244. listLoading: false,
  245. listQuery: {
  246. page: 1,
  247. limit: 100
  248. },
  249. dataForm: {
  250. id: undefined
  251. },
  252. dialogFormVisible: false,
  253. submiting: false,
  254. dialogStatus: '',
  255. textMap: {
  256. update: '编辑',
  257. create: '创建'
  258. },
  259. rules: {}
  260. }
  261. },
  262. created() { debugger
  263. this.listQuery.id = this.$route.query.id
  264. this.getList()
  265. },
  266. methods: {
  267. getList() {
  268. this.listLoading = true
  269. listCustomerBillingDetail(this.listQuery)
  270. .then(response => {
  271. debugger
  272. this.dataForm = response.data.data
  273. this.list = response.data.data.customerBillingDetailDOList
  274. this.total = response.data.data.total
  275. this.listLoading = false
  276. })
  277. .catch(() => {
  278. this.list = []
  279. this.total = 0
  280. this.listLoading = false
  281. })
  282. },
  283. returnsales() {
  284. this.$router.push({
  285. path: 'customerBilling'
  286. })
  287. },
  288. handleSelectionChange(val) {
  289. this.modification = val
  290. },
  291. selectInit(row) {
  292. return true
  293. },
  294. getSummaries(param) {
  295. const { columns, data } = param
  296. const sums = []
  297. columns.forEach((column, index) => {
  298. if (index === 0) {
  299. sums[index] = '合计'
  300. return
  301. } else if (
  302. index == 7 ||
  303. index == 8 ||
  304. index == 10 ||
  305. index == 11 ||
  306. index == 12||
  307. index == 13||
  308. index == 14
  309. ) {
  310. const values = data.map(item => Number(item[column.property]))
  311. if (!values.every(value => isNaN(value))) {
  312. sums[index] = values.reduce((prev, curr) => {
  313. const value = Number(curr)
  314. if (!isNaN(value)) {
  315. return prev + curr
  316. } else {
  317. return prev
  318. }
  319. }, 0)
  320. sums[index] += ''
  321. } else {
  322. sums[index] = '--'
  323. }
  324. } else {
  325. // sums[index] = "--";
  326. }
  327. })
  328. return sums
  329. },
  330. addDetail() {
  331. console.log('add')
  332. this.list.push({
  333. cabinetNo: '',
  334. arrivalDate: '',
  335. deliveryPlace: '',
  336. product: '',
  337. weight: '',
  338. clearanceFee: '',
  339. clearanceCost: '',
  340. truck: '',
  341. truckCost: '',
  342. otherExpenses: '',
  343. otherCost: '',
  344. pricePayable: '',
  345. cost: '',
  346. remarks: '',
  347. remark: '',
  348. status: ''
  349. })
  350. },
  351. handleFilter() {
  352. this.listQuery.page = 1
  353. this.getList()
  354. },
  355. resetForm() {
  356. this.dataForm = {
  357. id: undefined
  358. }
  359. },
  360. handleCreate() {
  361. this.resetForm()
  362. this.dialogStatus = 'create'
  363. this.dialogFormVisible = true
  364. this.$nextTick(() => {
  365. this.$refs['dataForm'].clearValidate()
  366. })
  367. },
  368. editData() {
  369. this.$refs['dataForm'].validate(valid => {
  370. if (valid) {
  371. this.submiting = true
  372. this.dataForm.customerBillingDetailDTOS = this.list
  373. editCustomerBillingInfo(this.dataForm)
  374. .then(response => {
  375. // this.list.unshift(response.data.data)
  376. this.dialogFormVisible = false
  377. this.$notify.success({
  378. title: '成功',
  379. message: '添加成功'
  380. })
  381. this.submiting = false
  382. this.returnsales()
  383. })
  384. .catch(response => {
  385. this.$notify.error({
  386. title: '失败',
  387. message: response.data.errmsg
  388. })
  389. this.submiting = false
  390. })
  391. }
  392. })
  393. },
  394. handleUpdate(row) {
  395. this.dataForm = Object.assign({}, row)
  396. this.dialogStatus = 'update'
  397. this.dialogFormVisible = true
  398. this.$nextTick(() => {
  399. this.$refs['dataForm'].clearValidate()
  400. })
  401. },
  402. updateData() {
  403. this.$refs['dataForm'].validate(valid => {
  404. if (valid) {
  405. this.submiting = true
  406. updateCustomerBillingInfo(this.dataForm)
  407. .then(() => {
  408. for (const v of this.list) {
  409. if (v.id === this.dataForm.id) {
  410. const index = this.list.indexOf(v)
  411. this.list.splice(index, 1, this.dataForm)
  412. break
  413. }
  414. }
  415. this.dialogFormVisible = false
  416. this.submiting = false
  417. this.$notify.success({
  418. title: '成功',
  419. message: '更新成功'
  420. })
  421. })
  422. .catch(response => {
  423. this.$notify.error({
  424. title: '失败',
  425. message: response.data.errmsg
  426. })
  427. this.submiting = false
  428. })
  429. }
  430. })
  431. },
  432. deleteRow(index, rows) {
  433. rows.splice(index, 1)
  434. }
  435. }
  436. }
  437. </script>
  438. <style lang="scss">
  439. .bg-left {
  440. padding-left: 30px;
  441. }
  442. .bg-right {
  443. padding-right: 10px;
  444. text-align: right;
  445. }
  446. .bg-bottom {
  447. margin: 15px 0px;
  448. }
  449. .title-style {
  450. background: #f6f7fc;
  451. border-radius: 5px;
  452. }
  453. .app-container {
  454. // background: ;
  455. }
  456. .title::before {
  457. content: "";
  458. display: inline-block;
  459. width: 5px;
  460. height: 30px;
  461. background: #5473e8;
  462. position: absolute;
  463. left: 0;
  464. }
  465. .position {
  466. position: relative;
  467. }
  468. .small-title {
  469. position: relative;
  470. padding: 10px;
  471. font-weight: 600;
  472. margin: 20px 0;
  473. }
  474. .small-title::before {
  475. position: absolute;
  476. content: "";
  477. display: block;
  478. background: #5473e8;
  479. width: 4px;
  480. height: 14px;
  481. left: 0px;
  482. top: 13px;
  483. }
  484. .el-form {
  485. padding: 0 40px;
  486. }
  487. .ws-info-table {
  488. display: -webkit-box;
  489. display: -ms-flexbox;
  490. display: flex;
  491. -ms-flex-wrap: wrap;
  492. flex-wrap: wrap;
  493. border-left: 1px solid #ccc;
  494. border-top: 1px solid #ccc;
  495. position: relative;
  496. border-left: 0;
  497. border-top: 0;
  498. }
  499. .input-width{
  500. width: 200px;
  501. }
  502. </style>