edit.vue 11 KB

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