edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="bulkWarehousingOrderEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 内容 -->
  5. <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
  6. <!-- 自定义的二级文字标题 -->
  7. <template slot="subTitle">
  8. <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  9. </template>
  10. </a-page-header>
  11. <!-- 基础信息 -->
  12. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  13. <a-collapse :activeKey="['1']" v-if="productTotal">
  14. <a-collapse-panel key="1">
  15. <template slot="header">
  16. 基础信息
  17. </template>
  18. <a-descriptions :column="3">
  19. <a-descriptions-item label="供应商">{{ (productTotal&&productTotal.supplierName) || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="入库类型">{{ (productTotal&&productTotal.sparePartsTypeDictValue) || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="入库单号">{{ (productTotal&&productTotal.sparePartsNo) || '--' }}</a-descriptions-item>
  22. </a-descriptions>
  23. </a-collapse-panel>
  24. </a-collapse>
  25. </a-card>
  26. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  27. <!-- 操作按钮 -->
  28. <div class="table-operator">
  29. <a-button id="bulkWarehousingOrderEdit-add" type="primary" class="button-primary" @click="handleEdit()">新增产品</a-button>
  30. <a-button id="bulkWarehousingOrderEdit-import" type="primary" class="button-primary" @click="openGuideModal=true">导入产品</a-button>
  31. </div>
  32. <!-- 总计 -->
  33. <a-alert type="info" v-if="productTotal" style="margin-bottom:10px">
  34. <div slot="message">
  35. 入库数量 <strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ,
  36. <span v-if="$hasPermissions('B_isShowCost')">入库金额 <strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? productTotal.totalPrice : '--' }}</strong></span>
  37. </div>
  38. </a-alert>
  39. <!-- 筛选条件 -->
  40. <div class="table-page-search-wrapper">
  41. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  42. <a-row :gutter="15">
  43. <a-col :md="6" :sm="24">
  44. <a-form-item label="产品编码" prop="productCode">
  45. <a-input id="allocateBillEdit-productCode" v-model="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  46. </a-form-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24">
  49. <a-form-item label="产品名称" prop="productName">
  50. <a-input id="allocateBillEdit-productName" v-model="queryParam.productName" placeholder="请输入产品名称" allowClear />
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  54. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
  55. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <!-- 列表 -->
  61. <s-table
  62. class="sTable"
  63. ref="table"
  64. size="small"
  65. :rowKey="(record) => record.id"
  66. :columns="columns"
  67. :data="loadData"
  68. :defaultLoadData="false"
  69. bordered>
  70. <!-- 操作 -->
  71. <template slot="action" slot-scope="text, record">
  72. <a-button
  73. size="small"
  74. type="link"
  75. @click="handleEdit(record)"
  76. class="button-info"
  77. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  78. <a-button
  79. size="small"
  80. type="link"
  81. @click="handleDel(record)"
  82. class="button-error"
  83. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  84. </template>
  85. </s-table>
  86. </a-card>
  87. </a-spin>
  88. <div class="affix-cont">
  89. <a-button
  90. type="primary"
  91. id="bulkWarehousingOrderEdit-submit"
  92. :disabled="spinning"
  93. size="large"
  94. class="button-primary"
  95. @click="handleBack"
  96. style="padding: 0 60px;">保存并返回</a-button>
  97. </div>
  98. <spare-parts-product-modal :openModal="openModal" :itemSn="itemSn" :nowData="productTotal" @ok="$refs.table.refresh(true)" @close="closeModal" />
  99. <!-- 导入产品 -->
  100. <importGuideModal :openModal="openGuideModal" :params="{sparePartsSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
  101. </div>
  102. </template>
  103. <script>
  104. import { STable, VSelect } from '@/components'
  105. import { getOperationalPrecision } from '@/libs/tools.js'
  106. import sparePartsProductModal from './productModal.vue'
  107. import ImportGuideModal from './importGuideModal.vue'
  108. import { sparePartsDetailList, sparePartsPageCount, sparePartsDeleteDetail, sparePartsDetailBatchInsert } from '@/api/spareParts'
  109. export default {
  110. components: { STable, VSelect, sparePartsProductModal, ImportGuideModal },
  111. data () {
  112. return {
  113. spinning: false,
  114. queryParam: {
  115. productCode: '',
  116. productName: ''
  117. },
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. return sparePartsDetailList(Object.assign(parameter, this.queryParam, { sparePartsSn: this.$route.params.sn })).then(res => {
  121. const data = res.data
  122. const no = (data.pageNo - 1) * data.pageSize
  123. for (var i = 0; i < data.list.length; i++) {
  124. data.list[i].no = no + i + 1
  125. // 小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  126. data.list[i].subtotal = getOperationalPrecision(data.list[i].productCost || 0, data.list[i].productQty)
  127. }
  128. this.getDetailCount(Object.assign(parameter, { sparePartsSn: this.$route.params.sn }))
  129. return data
  130. })
  131. },
  132. openModal: false, // 选择基本信息弹框是否显示
  133. basicInfoData: null, // 基本信息
  134. productTotal: null, // 合计
  135. itemSn: '',
  136. openGuideModal: false // 导入产品引导
  137. }
  138. },
  139. computed: {
  140. columns () {
  141. const arr = [
  142. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  143. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  145. { title: '单位', dataIndex: 'unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '入库数量', dataIndex: 'productQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. // { title: '入库单价', dataIndex: 'productCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  148. { title: '小计', dataIndex: 'subtotal', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  150. ]
  151. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  152. arr.splice(5, 0, { title: '入库单价', dataIndex: 'productCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  153. }
  154. return arr
  155. }
  156. },
  157. methods: {
  158. // 添加/编辑
  159. handleEdit (row) {
  160. this.itemSn = (row && row.sparePartsDetailSn) ? row.sparePartsDetailSn : null
  161. this.openModal = true
  162. },
  163. // 关闭
  164. closeModal () {
  165. this.itemSn = ''
  166. this.openModal = false
  167. },
  168. // 删除
  169. handleDel (row) {
  170. const _this = this
  171. this.$confirm({
  172. title: '提示',
  173. content: '删除后不可恢复,确定要进行删除吗?',
  174. centered: true,
  175. onOk () {
  176. _this.spinning = true
  177. sparePartsDeleteDetail({ sn: row.sparePartsDetailSn }).then(res => {
  178. if (res.status == 200) {
  179. _this.$message.success(res.message)
  180. _this.$refs.table.refresh()
  181. _this.spinning = false
  182. } else {
  183. _this.spinning = false
  184. }
  185. })
  186. }
  187. })
  188. },
  189. // 重置
  190. resetSearchForm () {
  191. this.queryParam.productCode = ''
  192. this.queryParam.productName = ''
  193. this.$refs.table.refresh(true)
  194. },
  195. // 导入产品
  196. hanldeOk (obj) {
  197. sparePartsDetailBatchInsert(obj).then(res => {
  198. if (res.status == 200) {
  199. this.$refs.table.refresh(true)
  200. }
  201. })
  202. },
  203. // 返回列表
  204. handleBack () {
  205. this.$router.push({ path: '/purchasingManagement/bulkWarehousingOrder/list', query: { closeLastOldTab: true } })
  206. },
  207. // 合计
  208. getDetailCount (params) {
  209. sparePartsPageCount(params).then(res => {
  210. if (res.status == 200) {
  211. this.productTotal = res.data
  212. } else {
  213. this.productTotal = null
  214. }
  215. })
  216. },
  217. pageInit () {
  218. this.productTotal = null
  219. this.openModal = false
  220. this.$refs.table.refresh(true)
  221. }
  222. },
  223. mounted () {
  224. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  225. this.pageInit()
  226. }
  227. },
  228. activated () {
  229. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  230. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  231. this.pageInit()
  232. }
  233. },
  234. beforeRouteEnter (to, from, next) {
  235. next(vm => {})
  236. }
  237. }
  238. </script>
  239. <style lang="less">
  240. .bulkWarehousingOrderEdit-wrap{
  241. position: relative;
  242. height: 100%;
  243. padding-bottom: 51px;
  244. box-sizing: border-box;
  245. >.ant-spin-nested-loading{
  246. overflow-y: scroll;
  247. height: 100%;
  248. }
  249. .bulkWarehousingOrderEdit-cont{
  250. margin-bottom: 10px;
  251. .table-operator{
  252. border: 0;
  253. padding-top: 0;
  254. }
  255. }
  256. }
  257. </style>