list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfNoMan-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="4" :sm="24">
  9. <a-form-item label="产品编码">
  10. <a-input id="shelfNoMan-code" v-model.trim="queryParam.product.code" allowClear placeholder="请输入产品编码"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="4" :sm="24">
  14. <a-form-item label="产品名称">
  15. <a-input id="shelfNoMan-name" v-model.trim="queryParam.product.name" allowClear placeholder="请输入产品名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="4" :sm="24">
  19. <a-form-item label="原厂编码">
  20. <a-input id="shelfNoMan-origCode" v-model.trim="queryParam.product.origCode" allowClear placeholder="请输入原厂编码"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="4" :sm="24">
  24. <a-form-item label="产品品牌">
  25. <ProductBrand id="shelfNoMan-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="4" :sm="24">
  30. <a-form-item label="产品分类">
  31. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="shelfNoMan-productType"></productTypeAll>
  32. </a-form-item>
  33. </a-col>
  34. <!-- <a-col :md="4" :sm="24" v-show="isShowWarehouse">
  35. <a-form-item label="仓库">
  36. <warehouse
  37. v-model="queryParam.product.warehouseSn"
  38. isPermission
  39. id="shelfNoMan-warehouseSn"
  40. placeholder="请选择仓库"
  41. />
  42. </a-form-item>
  43. </a-col> -->
  44. <a-col :md="4" :sm="24">
  45. <a-form-item label="产品状态">
  46. <v-select code="PRODUCT_STATUS" id="shelfNoMan-state" v-model="queryParam.product.state" allowClear placeholder="请选择产品状态"></v-select>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="4" :sm="24">
  50. <a-form-item label="货位编号">
  51. <a-input id="shelfNoMan-stackPlaceCode" v-model.trim="queryParam.stackPlaceCode" allowClear placeholder="请输入货位编号"/>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :md="4" :sm="24">
  55. <a-form-item label="是否有货位编号">
  56. <a-select id="shelfNoMan-haveStackCode" v-model="queryParam.haveStackCode" allowClear placeholder="请选择">
  57. <a-select-option value="1">
  58. 有编号
  59. </a-select-option>
  60. <a-select-option value="0">
  61. 无编号
  62. </a-select-option>
  63. </a-select>
  64. </a-form-item>
  65. </a-col>
  66. </template>
  67. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  68. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfNoMan-refresh">查询</a-button>
  69. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfNoMan-reset">重置</a-button>
  70. <a-button
  71. v-if="$hasPermissions('B_shelfNoManage_export')"
  72. style="margin-left: 5px"
  73. type="primary"
  74. class="button-warning"
  75. @click="handleExport"
  76. :disabled="disabled"
  77. :loading="exportLoading"
  78. id="shelfNoMan-export">导出</a-button>
  79. <a @click="advanced=!advanced" style="margin-left: 5px">
  80. {{ advanced ? '收起' : '展开' }}
  81. <a-icon :type="advanced ? 'up' : 'down'"/>
  82. </a>
  83. </a-col>
  84. </a-row>
  85. </a-form>
  86. </div>
  87. <!-- 操作按钮 -->
  88. <div class="table-operator">
  89. <a-button
  90. id="shelfNoMan-batchAudit"
  91. v-if="$hasPermissions('B_shelfNoManage_import')"
  92. type="primary"
  93. @click="openGuideModal = true"
  94. >批量导入</a-button>
  95. </div>
  96. <s-table
  97. class="sTable fixPagination"
  98. ref="table"
  99. :style="{ height: tableHeight+84.5+'px' }"
  100. size="small"
  101. :rowKey="(record) => record.id"
  102. :columns="columns"
  103. :data="loadData"
  104. :scroll="{ y: tableHeight }"
  105. :defaultLoadData="false"
  106. bordered>
  107. <!-- 产品分类 -->
  108. <template slot="productType" slot-scope="text, record">
  109. <span v-if="record.productVO.productTypeName2 || record.productVO.productTypeName3">{{ record.productVO.productTypeName2 }} {{ record.productVO.productTypeName3 ? '>' : '' }} {{ record.productVO.productTypeName3 }}</span>
  110. <span v-else>--</span>
  111. </template>
  112. <!-- 操作 -->
  113. <template slot="action" slot-scope="text, record">
  114. <div>
  115. <a-button
  116. size="small"
  117. type="link"
  118. v-if="$hasPermissions('B_shelfNoManage_edit')"
  119. class="button-info"
  120. @click="handleEdit(record)"
  121. id="shelfNoMan-edit-btn">编辑</a-button>
  122. <a-button
  123. size="small"
  124. type="link"
  125. v-if="$hasPermissions('B_shelfNoManage_detail')"
  126. class="button-success"
  127. @click="handleDetail(record)"
  128. id="shelfNoMan-detail-btn">变更记录</a-button>
  129. </div>
  130. </template>
  131. </s-table>
  132. </a-spin>
  133. <!-- 导入产品 -->
  134. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeOk" />
  135. <!-- 编辑 -->
  136. <editHwModal v-drag :openModal="openModal" :nowData="nowData" @ok="editOk" @close="closeModal" />
  137. <!-- 变更记录 -->
  138. <changeRecordModal v-drag :openModal="recordModal" :detailData="nowData" @close="closeModal"></changeRecordModal>
  139. </a-card>
  140. </template>
  141. <script>
  142. import { commonMixin } from '@/utils/mixin'
  143. import { STable, VSelect } from '@/components'
  144. import editHwModal from './editHwModal.vue'
  145. import ProductBrand from '@/views/common/productBrand.js'
  146. import productTypeAll from '@/views/common/productTypeAll.js'
  147. import { exportExcel } from '@/libs/JGPrint.js'
  148. import ImportGuideModal from './importGuideModal.vue'
  149. import changeRecordModal from './changeRecordModal.vue'
  150. import warehouse from '@/views/common/chooseWarehouse.js'
  151. import { queryStackPlaceQueryPage, stackPlaceExport, stackPlaceInsertImport } from '@/api/product'
  152. export default {
  153. name: 'ProductInfoList',
  154. mixins: [commonMixin],
  155. components: { STable, VSelect, editHwModal, ProductBrand, productTypeAll, ImportGuideModal, changeRecordModal, warehouse },
  156. data () {
  157. return {
  158. spinning: false,
  159. openGuideModal: false,
  160. advanced: true, // 高级搜索 展开/关闭
  161. tableHeight: 0,
  162. queryParam: { // 查询条件
  163. stackPlaceCode: undefined, // 货位编号
  164. haveStackCode: undefined,
  165. product: {
  166. name: '', // 产品名称
  167. code: '', // 产品编码
  168. origCode: '', // 原厂编码
  169. productBrandSn: undefined, // 产品品牌
  170. productTypeSn1: '', // 产品一级分类
  171. productTypeSn2: '', // 产品二级分类
  172. productTypeSn3: '', // 产品三级分类
  173. warehouseSn: undefined, // 仓库
  174. state: undefined // 产品状态
  175. }
  176. },
  177. productType: [],
  178. disabled: false, // 查询、重置按钮是否可操作
  179. exportLoading: false,
  180. loadingAudit: false,
  181. loadingLaunch: false,
  182. loadingDownline: false,
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. this.disabled = true
  186. this.spinning = true
  187. return queryStackPlaceQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  188. let data
  189. if (res.status == 200) {
  190. data = res.data
  191. const no = (data.pageNo - 1) * data.pageSize
  192. for (var i = 0; i < data.list.length; i++) {
  193. data.list[i].no = no + i + 1
  194. }
  195. this.disabled = false
  196. }
  197. this.spinning = false
  198. return data
  199. })
  200. },
  201. openModal: false, // 编辑弹框
  202. recordModal: false, // 变更记录弹框
  203. nowData: null, // 当前sn
  204. pageFromInfo: null
  205. }
  206. },
  207. computed: {
  208. columns () {
  209. const arr = [
  210. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  211. { title: '产品编码', dataIndex: 'productVO.code', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '产品名称', dataIndex: 'productVO.name', align: 'center', width: '20%', ellipsis: true, customRender: function (text) { return text || '--' } },
  213. { title: '原厂编码', dataIndex: 'productVO.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '产品品牌', dataIndex: 'productVO.productBrandName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'center' },
  216. // { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  217. { title: '产品状态', dataIndex: 'productVO.stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '货位编号', dataIndex: 'stackPlaceCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  220. ]
  221. if (this.isShowWarehouse) {
  222. // arr.splice(6, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  223. }
  224. return arr
  225. }
  226. },
  227. methods: {
  228. // 导入产品
  229. hanldeOk (obj) {
  230. stackPlaceInsertImport(obj).then(res => {
  231. if (res.status == 200) {
  232. this.resetSearchForm()
  233. }
  234. })
  235. },
  236. // 重置
  237. resetSearchForm () {
  238. this.queryParam = {
  239. stackPlaceCode: undefined, // 货位编号
  240. haveStackCode: undefined,
  241. product: {
  242. name: '', // 产品名称
  243. code: '', // 产品编码
  244. origCode: '', // 原厂编码
  245. productBrandSn: undefined, // 产品品牌
  246. productTypeSn1: '', // 产品一级分类
  247. productTypeSn2: '', // 产品二级分类
  248. productTypeSn3: '', // 产品三级分类
  249. warehouseSn: undefined, // 仓库
  250. state: undefined // 产品状态
  251. }
  252. }
  253. this.productType = []
  254. this.$refs.table.refresh(true)
  255. },
  256. // 编辑
  257. handleEdit (row) {
  258. this.nowData = row
  259. this.openModal = true
  260. },
  261. // 编辑成功
  262. editOk () {
  263. this.closeModal()
  264. this.$refs.table.refresh()
  265. },
  266. // 关闭编辑弹框
  267. closeModal () {
  268. this.nowData = null
  269. this.openModal = false
  270. this.recordModal = false
  271. },
  272. // 变更记录
  273. handleDetail (row) {
  274. this.nowData = row
  275. this.recordModal = true
  276. },
  277. // 导出
  278. handleExport () {
  279. const _this = this
  280. const params = this.queryParam
  281. this.spinning = true
  282. exportExcel(stackPlaceExport, params, '货位编号导出', function () {
  283. _this.spinning = false
  284. })
  285. },
  286. // 产品分类 change
  287. changeProductType (val, opt) {
  288. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  289. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  290. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  291. },
  292. pageInit () {
  293. const _this = this
  294. this.$nextTick(() => { // 页面渲染完成后的回调
  295. _this.setTableH()
  296. })
  297. },
  298. setTableH () {
  299. const tableSearchH = this.$refs.tableSearch.offsetHeight
  300. this.tableHeight = window.innerHeight - tableSearchH - 235
  301. }
  302. },
  303. watch: {
  304. advanced (newValue, oldValue) {
  305. const _this = this
  306. this.$nextTick(() => { // 页面渲染完成后的回调
  307. _this.setTableH()
  308. })
  309. },
  310. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  311. this.setTableH()
  312. }
  313. },
  314. mounted () {
  315. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  316. this.pageInit()
  317. this.resetSearchForm()
  318. }
  319. },
  320. activated () {
  321. // 如果是新页签打开,则重置当前页面
  322. if (this.$store.state.app.isNewTab) {
  323. this.pageInit()
  324. this.resetSearchForm()
  325. }
  326. },
  327. beforeRouteEnter (to, from, next) {
  328. next(vm => {
  329. vm.pageFromInfo = from
  330. })
  331. }
  332. }
  333. </script>