edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="chainTransferInEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="chainTransferInEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="chainTransferInEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra" v-if="$hasPermissions('B_allocLinkagePutPrint')">
  11. <a-radio-group key="3" v-model="printerType">
  12. <a-radio value="NEEDLE">针式</a-radio>
  13. <a-radio value="INK">喷墨</a-radio>
  14. </a-radio-group>
  15. <a-button key="2" id="chainTransferInEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  16. <a-button key="1" type="primary" id="chainTransferInEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  17. </template>
  18. </a-page-header>
  19. <!-- 基础信息 -->
  20. <a-card size="small" :bordered="false" class="chainTransferInEdit-cont">
  21. <a-collapse :activeKey="['1']">
  22. <a-collapse-panel key="1" header="基础信息">
  23. <a-descriptions :column="3">
  24. <a-descriptions-item label="调入单号">{{ (basicInfoData&&basicInfoData.allocationLinkagePutNo) || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="调出对象">{{ (basicInfoData&&basicInfoData.outTenantName) || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="财务状态">{{ (basicInfoData&&basicInfoData.settleStateDictValue) || '--' }}</a-descriptions-item>
  28. </a-descriptions>
  29. </a-collapse-panel>
  30. </a-collapse>
  31. </a-card>
  32. <a-card size="small" :bordered="false" class="chainTransferInEdit-cont">
  33. <!-- 总计 -->
  34. <a-alert type="info" style="margin-bottom: 10px">
  35. <div slot="message">
  36. 总款数 <strong>{{ (basicInfoData&&(basicInfoData.productTotalCategory || basicInfoData.productTotalCategory==0)) ? basicInfoData.productTotalCategory : '--' }}</strong> ,
  37. 总数量 <strong>{{ (basicInfoData&&(basicInfoData.productTotalQty || basicInfoData.productTotalQty==0)) ? basicInfoData.productTotalQty : '--' }}</strong> ,
  38. 总成本 <strong>{{ (basicInfoData&&(basicInfoData.productTotalCost || basicInfoData.productTotalCost==0)) ? '¥'+basicInfoData.productTotalCost : '--' }}</strong>
  39. </div>
  40. </a-alert>
  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="chainTransferInEdit-productCode" v-model="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="chainTransferInEdit-productName" v-model="queryParam.productName" placeholder="请输入产品名称" allowClear />
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="产品分类">
  57. <a-cascader
  58. @change="changeProductType"
  59. change-on-select
  60. v-model="productType"
  61. expand-trigger="hover"
  62. :options="productTypeList"
  63. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  64. id="chainTransferInEdit-productType"
  65. placeholder="请选择产品分类"
  66. allowClear />
  67. </a-form-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  70. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chainTransferInEdit-refresh">查询</a-button>
  71. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="chainTransferInEdit-reset">重置</a-button>
  72. </a-col>
  73. </a-row>
  74. </a-form>
  75. </div>
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable"
  79. ref="table"
  80. size="small"
  81. :rowKey="(record) => record.id"
  82. :columns="columns"
  83. :data="loadData"
  84. :defaultLoadData="false"
  85. :scroll="{ x: 1110 }"
  86. bordered>
  87. <!-- 仓库仓位 -->
  88. <template slot="warehouse" slot-scope="text, record, index">
  89. <a-cascader
  90. size="small"
  91. @change="e => changeWarehouseCascade(e, record, index)"
  92. v-model="record.warehouseCascade"
  93. expand-trigger="hover"
  94. :allowClear="false"
  95. :options="warehouseCascadeData"
  96. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  97. id="chainTransferInEdit-warehouseCascade"
  98. placeholder="请选择仓库仓位"
  99. style="width: 100%;" />
  100. </template>
  101. </s-table>
  102. </a-card>
  103. </a-spin>
  104. <div class="affix-cont">
  105. <a-button
  106. type="primary"
  107. id="chainTransferInEdit-submit"
  108. size="large"
  109. class="button-primary"
  110. :disabled="spinning"
  111. @click="handleSubmit"
  112. style="padding: 0 60px;">提交入库</a-button>
  113. </div>
  114. <!-- 打印 -->
  115. <div id="print"></div>
  116. </div>
  117. </template>
  118. <script>
  119. import { STable, VSelect } from '@/components'
  120. import { getOperationalPrecision } from '@/libs/tools.js'
  121. import { dealerProductTypeList } from '@/api/dealerProductType'
  122. import { warehouseCascadeList } from '@/api/warehouse'
  123. import { allocLinkagePutDetailSn, allocLinkagePutDetailList, allocLinkagePutDetailCount, allocLinkagePutDetailUpdate, allocLinkagePutSubmit, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
  124. export default {
  125. components: { STable, VSelect },
  126. data () {
  127. return {
  128. spinning: false,
  129. queryParam: {
  130. productCode: '', // 产品编码
  131. productName: '', // 产品名称
  132. productTypeSn1: '', // 产品分类1
  133. productTypeSn2: '', // 产品分类2
  134. productTypeSn3: '' // 产品分类3
  135. },
  136. disabled: false, // 查询、重置按钮是否可操作
  137. productTypeList: [], // 产品分类 下拉数据
  138. productType: [],
  139. warehouseCascadeData: [], // 仓库仓位
  140. // 表头
  141. columns: [
  142. { title: '序号', dataIndex: 'no', width: 70, align: 'center', fixed: 'left' },
  143. { title: '产品编码', dataIndex: 'productCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  145. { title: '原厂编码', dataIndex: 'productOrigCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '成本价', dataIndex: 'putCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '调入数量', dataIndex: 'putQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  148. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '成本小计', dataIndex: 'costSubtotal', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 200, align: 'center' }
  151. ],
  152. // 加载数据方法 必须为 Promise 对象
  153. loadData: parameter => {
  154. this.disabled = true
  155. this.spinning = true
  156. const params = Object.assign(parameter, this.queryParam, { allocationLinkagePutSn: this.$route.params.sn })
  157. return allocLinkagePutDetailList(params).then(res => {
  158. this.getDetailCount(params)
  159. const data = res.data
  160. const no = (data.pageNo - 1) * data.pageSize
  161. for (var i = 0; i < data.list.length; i++) {
  162. data.list[i].no = no + i + 1
  163. const warehouseSn = data.list[i].warehouseSn || undefined
  164. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  165. data.list[i].warehouseSnBackups = warehouseSn
  166. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  167. if (warehouseSn || warehouseLocationSn) {
  168. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  169. } else {
  170. data.list[i].warehouseCascade = undefined
  171. }
  172. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  173. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  174. }
  175. this.localDataSource = data.list || []
  176. this.disabled = false
  177. this.spinning = false
  178. return data
  179. })
  180. },
  181. localDataSource: [],
  182. basicInfoData: null, // 基本信息
  183. productTotal: null, // 合计
  184. printerType: 'NEEDLE' // 打印机类型
  185. }
  186. },
  187. methods: {
  188. // 重置
  189. resetSearchForm () {
  190. this.queryParam.productCode = ''
  191. this.queryParam.productName = ''
  192. this.queryParam.productTypeSn1 = ''
  193. this.queryParam.productTypeSn2 = ''
  194. this.queryParam.productTypeSn3 = ''
  195. this.productType = []
  196. this.$refs.table.refresh(true)
  197. },
  198. // 基本信息
  199. getDetail () {
  200. allocLinkagePutDetailSn({ sn: this.$route.params.sn }).then(res => {
  201. if (res.status == 200) {
  202. this.basicInfoData = res.data
  203. this.getProductType()
  204. } else {
  205. this.basicInfoData = null
  206. }
  207. })
  208. },
  209. // 提交
  210. handleSubmit () {
  211. this.spinning = true
  212. allocLinkagePutSubmit({ sn: this.$route.params.sn }).then(res => {
  213. if (res.status == 200) {
  214. this.$message.success(res.message)
  215. this.handleBack()
  216. this.spinning = false
  217. } else {
  218. this.spinning = false
  219. }
  220. })
  221. },
  222. // 合计
  223. getDetailCount (params) {
  224. allocLinkagePutDetailCount(params).then(res => {
  225. if (res.status == 200) {
  226. this.productTotal = res.data
  227. } else {
  228. this.productTotal = null
  229. }
  230. })
  231. },
  232. // 返回列表
  233. handleBack () {
  234. this.$router.push({ path: '/allocationManagement/chainTransferIn/list', query: { closeLastOldTab: true } })
  235. },
  236. // 产品分类 change
  237. changeProductType (val, opt) {
  238. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  239. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  240. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  241. },
  242. changeWarehouseCascade (val, opt, ind) {
  243. if (val.length < 2) {
  244. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  245. const warehouseSnBackups = this.localDataSource[ind].warehouseSnBackups || undefined
  246. const warehouseLocationSnBackups = this.localDataSource[ind].warehouseLocationSnBackups || undefined
  247. this.localDataSource[ind].warehouseSn = warehouseSnBackups
  248. this.localDataSource[ind].warehouseLocationSn = warehouseLocationSnBackups
  249. if (warehouseSnBackups || warehouseLocationSnBackups) {
  250. this.localDataSource[ind].warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  251. } else {
  252. this.localDataSource[ind].warehouseCascade = undefined
  253. }
  254. } else {
  255. this.localDataSource[ind].warehouseSn = val[0] ? val[0] : ''
  256. this.localDataSource[ind].warehouseLocationSn = val[1] ? val[1] : ''
  257. this.handleAdd(this.localDataSource[ind])
  258. }
  259. },
  260. // 添加/编辑
  261. handleAdd (row) {
  262. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  263. if (!row.warehouseSn) {
  264. row.warehouseSn = row.warehouseSnBackups
  265. return
  266. }
  267. if (!row.warehouseLocationSn) {
  268. row.warehouseLocationSn = row.warehouseLocationSnBackups
  269. return
  270. }
  271. const params = {
  272. id: row.id,
  273. warehouseLocationSn: row.warehouseLocationSn,
  274. warehouseSn: row.warehouseSn
  275. }
  276. this.spinning = true
  277. allocLinkagePutDetailUpdate(params).then(res => {
  278. if (res.status == 200) {
  279. this.$message.success(res.message)
  280. this.$refs.table.refresh()
  281. this.spinning = false
  282. } else {
  283. this.spinning = false
  284. }
  285. })
  286. },
  287. // 产品分类 列表
  288. getProductType () {
  289. dealerProductTypeList({ sysFlag: this.basicInfoData.allocationType == 'JIANGUAN' ? '1' : '0' }).then(res => {
  290. if (res.status == 200) {
  291. this.productTypeList = res.data
  292. } else {
  293. this.productTypeList = []
  294. }
  295. })
  296. },
  297. getWarehouseCascade () {
  298. warehouseCascadeList({}).then(res => {
  299. if (res.status == 200) {
  300. res.data.map(item => {
  301. item.sn = item.warehouseSn
  302. if (item.warehouseLocationList) {
  303. item.warehouseLocationList.map(subItem => {
  304. subItem.sn = subItem.warehouseLocationSn
  305. })
  306. }
  307. })
  308. this.warehouseCascadeData = res.data
  309. } else {
  310. this.warehouseCascadeData = []
  311. }
  312. })
  313. },
  314. // 打印预览/快捷打印
  315. handlePrint (type) {
  316. const _this = this
  317. _this.spinning = true
  318. allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
  319. _this.spinning = false
  320. if (res.type == 'application/json') {
  321. var reader = new FileReader()
  322. reader.addEventListener('loadend', function () {
  323. const obj = JSON.parse(reader.result)
  324. _this.$notification.error({
  325. message: '提示',
  326. description: obj.message
  327. })
  328. })
  329. reader.readAsText(res)
  330. } else {
  331. this.print(res, type)
  332. }
  333. })
  334. },
  335. print (data, type) {
  336. if (!data) {
  337. return
  338. }
  339. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  340. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  341. if (type == 'preview') { // 预览
  342. window.open(url)
  343. } else if (type == 'print') { // 打印
  344. window.frames['printf'].focus()
  345. window.frames['printf'].print()
  346. }
  347. }
  348. },
  349. mounted () {
  350. this.getDetail()
  351. },
  352. beforeRouteEnter (to, from, next) {
  353. next(vm => {
  354. vm.getWarehouseCascade()
  355. if (!vm.disabled) {
  356. vm.getDetail()
  357. vm.resetSearchForm()
  358. }
  359. })
  360. }
  361. }
  362. </script>
  363. <style lang="less">
  364. .chainTransferInEdit-wrap{
  365. position: relative;
  366. height: 100%;
  367. padding-bottom: 51px;
  368. box-sizing: border-box;
  369. .chainTransferInEdit-back, .chainTransferInEdit-cont{
  370. margin-bottom: 10px;
  371. }
  372. >.ant-spin-nested-loading{
  373. overflow-y: scroll;
  374. height: 100%;
  375. }
  376. }
  377. </style>