edit.vue 11 KB

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