edit.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="bulkWarehousingOrderEdit-wrap">
  3. <!-- 内容 -->
  4. <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra">
  11. <a-button key="2" id="bulkWarehousingOrderEdit-preview-btn">打印预览</a-button>
  12. <a-button key="1" type="primary" id="bulkWarehousingOrderEdit-print-btn">快速打印</a-button>
  13. </template>
  14. </a-page-header>
  15. <!-- 基础信息 -->
  16. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  17. <a-collapse :activeKey="['1']">
  18. <a-collapse-panel key="1">
  19. <template slot="header">
  20. 基础信息
  21. </template>
  22. <a-descriptions :column="3">
  23. <a-descriptions-item label="供应商">{{ (productTotal&&productTotal.supplierName) || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="入库类型">{{ (productTotal&&productTotal.sparePartsTypeDictValue) || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="入库单号">{{ (productTotal&&productTotal.sparePartsNo) || '--' }}</a-descriptions-item>
  26. </a-descriptions>
  27. </a-collapse-panel>
  28. </a-collapse>
  29. </a-card>
  30. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  31. <!-- 操作按钮 -->
  32. <div class="table-operator">
  33. <a-button id="bulkWarehousingOrderEdit-add" type="primary" class="button-error" @click="handleEdit()">新增产品</a-button>
  34. </div>
  35. <!-- 总计 -->
  36. <a-alert type="info" showIcon style="margin-bottom:15px">
  37. <div slot="message">入库数量 <strong>{{ (productTotal&&productTotal.totalQty) || 0 }}</strong> ,入库金额 <strong>{{ (productTotal&&productTotal.totalPrice) || 0 }}</strong></div>
  38. </a-alert>
  39. <!-- 列表 -->
  40. <s-table
  41. class="sTable"
  42. ref="table"
  43. size="small"
  44. :rowKey="(record) => record.id"
  45. :columns="columns"
  46. :data="loadData"
  47. bordered>
  48. <!-- 操作 -->
  49. <template slot="action" slot-scope="text, record">
  50. <a-button
  51. size="small"
  52. type="link"
  53. @click="handleEdit(record)"
  54. class="button-info"
  55. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  56. <a-button
  57. size="small"
  58. type="link"
  59. @click="handleDel(record)"
  60. class="button-error"
  61. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  62. </template>
  63. </s-table>
  64. </a-card>
  65. <a-affix :offset-bottom="0">
  66. <div style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
  67. <a-button
  68. type="primary"
  69. id="bulkWarehousingOrderEdit-submit"
  70. size="large"
  71. class="button-primary"
  72. @click="handleBack"
  73. style="padding: 0 60px;">保存并返回</a-button>
  74. </div>
  75. </a-affix>
  76. <spare-parts-product-modal :openModal="openModal" :itemSn="itemSn" :nowData="productTotal" @ok="$refs.table.refresh(true)" @close="openModal=false" />
  77. </div>
  78. </template>
  79. <script>
  80. import { STable, VSelect } from '@/components'
  81. import { getOperationalPrecision } from '@/libs/tools.js'
  82. import sparePartsProductModal from './productModal.vue'
  83. import { sparePartsDetailList, sparePartsPageCount, sparePartsDeleteDetail } from '@/api/spareParts'
  84. export default {
  85. components: { STable, VSelect, sparePartsProductModal },
  86. data () {
  87. return {
  88. // 表头
  89. columns: [
  90. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  91. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  93. { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '入库数量', dataIndex: 'productQty', width: 100, align: 'center' },
  95. { title: '入库单价', dataIndex: 'productCost', width: 100, align: 'center' },
  96. { title: '小计', dataIndex: 'subtotal', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  97. { title: '操作', scopedSlots: { customRender: 'action' }, width: 120, align: 'center', fixed: 'right' }
  98. ],
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. return sparePartsDetailList(Object.assign(parameter, { sn: this.$route.params.sn })).then(res => {
  102. const data = res.data
  103. const no = (data.pageNo - 1) * data.pageSize
  104. for (var i = 0; i < data.list.length; i++) {
  105. data.list[i].no = no + i + 1
  106. // 小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  107. data.list[i].subtotal = getOperationalPrecision(data.list[i].productCost, data.list[i].productQty)
  108. }
  109. this.getDetailCount(Object.assign(parameter, { sn: this.$route.params.sn }))
  110. return data
  111. })
  112. },
  113. openModal: false, // 选择基本信息弹框是否显示
  114. basicInfoData: null, // 基本信息
  115. productTotal: null, // 合计
  116. itemSn: ''
  117. }
  118. },
  119. methods: {
  120. // 添加/编辑
  121. handleEdit (row) {
  122. this.itemSn = (row && row.sparePartsDetailSn) ? row.sparePartsDetailSn : null
  123. this.openModal = true
  124. },
  125. // 删除
  126. handleDel (row) {
  127. const _this = this
  128. this.$confirm({
  129. title: '提示',
  130. content: '删除后不可恢复,确定要进行删除吗?',
  131. centered: true,
  132. onOk () {
  133. sparePartsDeleteDetail({ sn: row.sparePartsDetailSn }).then(res => {
  134. if (res.status == 200) {
  135. _this.$message.success(res.message)
  136. _this.$refs.table.refresh()
  137. }
  138. })
  139. }
  140. })
  141. },
  142. // 返回列表
  143. handleBack () {
  144. this.$router.push({ path: '/purchasingManagement/bulkWarehousingOrder/list' })
  145. },
  146. // 合计
  147. getDetailCount (params) {
  148. sparePartsPageCount(params).then(res => {
  149. if (res.status == 200) {
  150. this.productTotal = res.data
  151. } else {
  152. this.productTotal = null
  153. }
  154. })
  155. }
  156. },
  157. beforeRouteEnter (to, from, next) {
  158. next(vm => {
  159. vm.openModal = false
  160. })
  161. }
  162. }
  163. </script>
  164. <style lang="less">
  165. .bulkWarehousingOrderEdit-wrap{
  166. .bulkWarehousingOrderEdit-cont{
  167. margin-bottom: 10px;
  168. }
  169. }
  170. </style>