detailModal.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <a-modal
  3. centered
  4. class="detail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="详情"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="70%">
  11. <a-card size="small" :bordered="false" class="detail-basics-info">
  12. <!-- 基础信息 -->
  13. <a-collapse :activeKey="['1']">
  14. <a-collapse-panel key="1">
  15. <template slot="header">
  16. 基础信息
  17. </template>
  18. <a-descriptions :column="3">
  19. <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="入库仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="采购单号">{{ (basicInfoData&&basicInfoData.lockBizNo) || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="客户名称">{{ (basicInfoData&&basicInfoData.lockBizDealerName) || '--' }}</a-descriptions-item>
  23. </a-descriptions>
  24. </a-collapse-panel>
  25. </a-collapse>
  26. <!-- 总计 -->
  27. <a-alert type="info" style="margin:10px 0">
  28. <div slot="message">
  29. 采购数量 <strong>{{ (statisticsObj&&(statisticsObj.productTotalQty || statisticsObj.productTotalQty==0)) ? statisticsObj.productTotalQty : '--' }}</strong> ,
  30. <span v-if="$hasPermissions('B_purchaseReceiptDetail_costPrice')">采购金额 <strong>{{ (statisticsObj&&(statisticsObj.productTotalCost || statisticsObj.productTotalCost==0)) ? toThousands(statisticsObj.productTotalCost) : '--' }}</strong></span>
  31. </div>
  32. </a-alert>
  33. <!-- 列表 -->
  34. <s-table
  35. class="sTable"
  36. ref="table"
  37. size="small"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :defaultLoadData="false"
  42. :scroll="{ y: 300 }"
  43. bordered>
  44. <!-- 操作 -->
  45. <template slot="action" slot-scope="text, record">
  46. <a-tooltip placement="bottom" v-if="record.traceCodeQty*1!=record.productQty*1">
  47. <template slot="title">
  48. <span>唯一码数量与采购数量不一致</span>
  49. </template>
  50. <a-button
  51. size="small"
  52. type="link"
  53. v-if="$hasPermissions('B_purchaseReceiptCode')"
  54. @click="handleCheck(record)"
  55. class="button-info"
  56. id="detail-edit-btn">
  57. 查看
  58. <a-icon type="exclamation" style="color:#f30;" />
  59. </a-button>
  60. </a-tooltip>
  61. <a-button
  62. size="small"
  63. type="link"
  64. v-if="$hasPermissions('B_purchaseReceiptCode')&&record.traceCodeQty*1===record.productQty*1"
  65. @click="handleCheck(record)"
  66. class="button-info"
  67. id="detail-edit-btn">查看</a-button>
  68. </template>
  69. </s-table>
  70. </a-card>
  71. <div class="btn-cont">
  72. <a-button id="detail-basicInfo-modal-back" @click="isShow = false">关闭</a-button>
  73. </div>
  74. <!-- 唯一码列表 不分页 -->
  75. <uniqueCodeModal v-drag :openModal="openUniqueCodeModal" :itemData="itemUniqueCodeData" @close="closeUniqueCodeModal" />
  76. </a-modal>
  77. </template>
  78. <script>
  79. import { commonMixin } from '@/utils/mixin'
  80. // 组件
  81. import { STable, VSelect } from '@/components'
  82. import uniqueCodeModal from './uniqueCodeModal.vue'
  83. // 接口
  84. import { sparePartsPageCount } from '@/api/spareParts'
  85. import { purchaseDetailPageList, queryDetailCount } from '@/api/purchase'
  86. export default {
  87. name: 'DetailModal',
  88. mixins: [commonMixin],
  89. components: { STable, VSelect, uniqueCodeModal },
  90. props: {
  91. openModal: { // 弹框显示状态
  92. type: Boolean,
  93. default: false
  94. },
  95. itemSn: {// sn
  96. type: [Number, String],
  97. default: ''
  98. }
  99. },
  100. data () {
  101. return {
  102. isShow: this.openModal, // 是否打开弹框
  103. basicInfoData: null, // 基础信息数据
  104. statisticsObj: null, // 统计数据
  105. openUniqueCodeModal: false, // 轮胎唯一码弹窗
  106. itemUniqueCodeData: null,
  107. // 加载数据方法 必须为 Promise 对象
  108. loadData: parameter => {
  109. const params = Object.assign(parameter, { sparePartsSn: this.itemSn })
  110. return purchaseDetailPageList(params).then(res => {
  111. let data
  112. if (res.status == 200) {
  113. data = res.data
  114. // 获取基础信息数据
  115. this.getBasicsData()
  116. // 获取统计数据
  117. this.getDetailCount()
  118. const no = (data.pageNo - 1) * data.pageSize
  119. for (var i = 0; i < data.list.length; i++) {
  120. data.list[i].no = no + i + 1
  121. }
  122. this.disabled = false
  123. }
  124. return data
  125. })
  126. }
  127. }
  128. },
  129. computed: {
  130. columns () {
  131. const arr = [
  132. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  133. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '原厂编码', dataIndex: 'productOrigCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  136. { title: '单位', dataIndex: 'unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '采购数量', dataIndex: 'productQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  138. // { title: '采购单价', dataIndex: 'productCost', width: '10%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  139. // { title: '采购金额', dataIndex: 'subtotal', width: '10%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') }
  140. ]
  141. if (this.$hasPermissions('B_purchaseReceiptDetail_costPrice')) { // 成本价权限
  142. arr.splice(6, 0, { title: '采购单价', dataIndex: 'productCost', width: '10%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  143. arr.splice(7, 0, { title: '采购金额', dataIndex: 'subtotal', width: '10%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  144. }
  145. if (this.basicInfoData && this.basicInfoData.state && this.basicInfoData.state === 'FINISH') {
  146. arr.push({ title: '唯一码', dataIndex: 'action', width: '10%', align: 'center', scopedSlots: { customRender: 'action' } })
  147. }
  148. return arr
  149. }
  150. },
  151. methods: {
  152. handleCheck (row) {
  153. this.itemUniqueCodeData = { purchaseNo: row.sparePartsNo, productCode: row.productCode, productSn: row.productSn }
  154. this.openUniqueCodeModal = true
  155. },
  156. closeUniqueCodeModal () {
  157. this.itemUniqueCodeData = null
  158. this.openUniqueCodeModal = false
  159. },
  160. // 获取基础信息
  161. getBasicsData () {
  162. queryDetailCount({ sn: this.itemSn }).then(res => {
  163. if (res.status == 200) {
  164. this.basicInfoData = res.data
  165. } else {
  166. this.basicInfoData = null
  167. }
  168. })
  169. },
  170. // 统计
  171. getDetailCount (params) {
  172. sparePartsPageCount({ sparePartsSn: this.itemSn }).then(res => {
  173. if (res.status == 200) {
  174. this.statisticsObj = res.data
  175. } else {
  176. this.statisticsObj = null
  177. }
  178. })
  179. }
  180. },
  181. watch: {
  182. // 父页面传过来的弹框状态
  183. openModal (newValue, oldValue) {
  184. this.isShow = newValue
  185. },
  186. // 重定义的弹框状态
  187. isShow (newValue, oldValue) {
  188. if (!newValue) {
  189. this.$emit('close')
  190. } else {
  191. this.$nextTick(() => {
  192. this.$refs.table.refresh()
  193. })
  194. }
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="less">
  200. .detail-modal{
  201. .ant-modal-body {
  202. padding: 10px 10px 20px;
  203. }
  204. .btn-cont {
  205. text-align: center;
  206. margin: 5px 0 10px;
  207. }
  208. }
  209. </style>