list.vue 13 KB

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