list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.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. <a-button type="primary" @click="openNewModal" class="button-warning" id="shelfNoMan-add">新增</a-button>
  96. </div>
  97. <s-table
  98. class="sTable fixPagination"
  99. ref="table"
  100. :style="{ height: tableHeight+84.5+'px' }"
  101. size="small"
  102. :rowKey="(record) => record.id"
  103. :columns="columns"
  104. :data="loadData"
  105. :scroll="{ y: tableHeight }"
  106. :defaultLoadData="false"
  107. bordered>
  108. <!-- 产品分类 -->
  109. <template slot="productType" slot-scope="text, record">
  110. <span v-if="record.product.productTypeName2 || record.product.productTypeName3">{{ record.product.productTypeName2 }} {{ record.product.productTypeName3 ? '>' : '' }} {{ record.product.productTypeName3 }}</span>
  111. <span v-else>--</span>
  112. </template>
  113. <!-- 操作 -->
  114. <template slot="action" slot-scope="text, record">
  115. <div>
  116. <a-button
  117. size="small"
  118. type="link"
  119. v-if="$hasPermissions('B_shelfNoManage_edit')"
  120. class="button-info"
  121. @click="handleEdit(record)"
  122. id="shelfNoMan-edit-btn">编辑</a-button>
  123. <a-button
  124. size="small"
  125. type="link"
  126. v-if="$hasPermissions('B_shelfNoManage_detail')"
  127. class="button-success"
  128. @click="handleDetail(record)"
  129. id="shelfNoMan-detail-btn">变更记录</a-button>
  130. </div>
  131. </template>
  132. </s-table>
  133. </a-spin>
  134. <!-- 导入产品 -->
  135. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeOk" />
  136. <!-- 编辑 -->
  137. <editHwModal v-drag :openModal="openModal" :nowData="nowData" @ok="editOk" @close="closeModal" />
  138. <!-- 变更记录 -->
  139. <changeRecordModal v-drag :openModal="recordModal" :detailData="nowData" @close="closeModal"></changeRecordModal>
  140. </a-card>
  141. </template>
  142. <script>
  143. import { commonMixin } from '@/utils/mixin'
  144. import { STable, VSelect } from '@/components'
  145. import editHwModal from './editHwModal.vue'
  146. import ProductBrand from '@/views/common/productBrand.js'
  147. import productTypeAll from '@/views/common/productTypeAll.js'
  148. import { exportExcel } from '@/libs/JGPrint.js'
  149. import ImportGuideModal from './importGuideModal.vue'
  150. import changeRecordModal from './changeRecordModal.vue'
  151. import warehouse from '@/views/common/chooseWarehouse.js'
  152. import { queryStackPlaceQueryPage, stackPlaceExport, stackPlaceInsertImport } from '@/api/product'
  153. export default {
  154. name: 'ProductInfoList',
  155. mixins: [commonMixin],
  156. components: { STable, VSelect, editHwModal, ProductBrand, productTypeAll, ImportGuideModal, changeRecordModal, warehouse },
  157. data () {
  158. return {
  159. spinning: false,
  160. openGuideModal: false,
  161. advanced: true, // 高级搜索 展开/关闭
  162. tableHeight: 0,
  163. queryParam: { // 查询条件
  164. stackPlaceCode: undefined, // 货位编号
  165. haveStackCode: undefined,
  166. product: {
  167. name: '', // 产品名称
  168. code: '', // 产品编码
  169. origCode: '', // 原厂编码
  170. productBrandSn: undefined, // 产品品牌
  171. productTypeSn1: '', // 产品一级分类
  172. productTypeSn2: '', // 产品二级分类
  173. productTypeSn3: '', // 产品三级分类
  174. state: undefined // 产品状态
  175. },
  176. warehouseSn: undefined, // 仓库
  177. },
  178. productType: [],
  179. disabled: false, // 查询、重置按钮是否可操作
  180. exportLoading: false,
  181. loadingAudit: false,
  182. loadingLaunch: false,
  183. loadingDownline: false,
  184. // 加载数据方法 必须为 Promise 对象
  185. loadData: parameter => {
  186. this.disabled = true
  187. this.spinning = true
  188. return queryStackPlaceQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  189. let data
  190. if (res.status == 200) {
  191. data = res.data
  192. const no = (data.pageNo - 1) * data.pageSize
  193. for (var i = 0; i < data.list.length; i++) {
  194. data.list[i].no = no + i + 1
  195. }
  196. this.disabled = false
  197. }
  198. this.spinning = false
  199. return data
  200. })
  201. },
  202. openModal: false, // 编辑弹框
  203. recordModal: false, // 变更记录弹框
  204. nowData: null, // 当前sn
  205. pageFromInfo: null
  206. }
  207. },
  208. computed: {
  209. columns () {
  210. const arr = [
  211. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  212. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '产品名称', dataIndex: 'product.name', align: 'center', width: '20%', ellipsis: true, customRender: function (text) { return text || '--' } },
  214. { title: '原厂编码', dataIndex: 'product.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '产品品牌', dataIndex: 'product.productBrandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'center' },
  217. { title: '产品状态', dataIndex: 'product.stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '货位编号', dataIndex: 'stackPlaceCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  221. ]
  222. return arr
  223. }
  224. },
  225. methods: {
  226. // 导入产品
  227. hanldeOk (obj) {
  228. stackPlaceInsertImport(obj).then(res => {
  229. if (res.status == 200) {
  230. this.resetSearchForm()
  231. }
  232. })
  233. },
  234. // 重置
  235. resetSearchForm () {
  236. this.queryParam = {
  237. stackPlaceCode: undefined, // 货位编号
  238. haveStackCode: undefined,
  239. warehouseSn: undefined, // 仓库
  240. product: {
  241. name: '', // 产品名称
  242. code: '', // 产品编码
  243. origCode: '', // 原厂编码
  244. productBrandSn: undefined, // 产品品牌
  245. productTypeSn1: '', // 产品一级分类
  246. productTypeSn2: '', // 产品二级分类
  247. productTypeSn3: '', // 产品三级分类
  248. state: undefined // 产品状态
  249. }
  250. }
  251. this.productType = []
  252. this.$refs.table.refresh(true)
  253. },
  254. // 新增
  255. openNewModal () {
  256. this.nowData = null
  257. this.openModal = true
  258. },
  259. // 编辑
  260. handleEdit (row) {
  261. this.nowData = row
  262. this.openModal = true
  263. },
  264. // 编辑成功
  265. editOk () {
  266. this.closeModal()
  267. this.$refs.table.refresh()
  268. },
  269. // 关闭编辑弹框
  270. closeModal () {
  271. this.nowData = null
  272. this.openModal = false
  273. this.recordModal = false
  274. },
  275. // 变更记录
  276. handleDetail (row) {
  277. this.nowData = row
  278. this.recordModal = true
  279. },
  280. // 导出
  281. handleExport () {
  282. const _this = this
  283. const params = this.queryParam
  284. this.spinning = true
  285. exportExcel(stackPlaceExport, params, '货位编号导出', function () {
  286. _this.spinning = false
  287. })
  288. },
  289. // 产品分类 change
  290. changeProductType (val, opt) {
  291. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  292. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  293. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  294. },
  295. pageInit () {
  296. const _this = this
  297. this.$nextTick(() => { // 页面渲染完成后的回调
  298. _this.setTableH()
  299. })
  300. },
  301. setTableH () {
  302. const tableSearchH = this.$refs.tableSearch.offsetHeight
  303. this.tableHeight = window.innerHeight - tableSearchH - 235
  304. }
  305. },
  306. watch: {
  307. advanced (newValue, oldValue) {
  308. const _this = this
  309. this.$nextTick(() => { // 页面渲染完成后的回调
  310. _this.setTableH()
  311. })
  312. },
  313. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  314. this.setTableH()
  315. }
  316. },
  317. mounted () {
  318. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  319. this.pageInit()
  320. this.resetSearchForm()
  321. }
  322. },
  323. activated () {
  324. // 如果是新页签打开,则重置当前页面
  325. if (this.$store.state.app.isNewTab) {
  326. this.pageInit()
  327. this.resetSearchForm()
  328. }
  329. },
  330. beforeRouteEnter (to, from, next) {
  331. next(vm => {
  332. vm.pageFromInfo = from
  333. })
  334. }
  335. }
  336. </script>