list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <a-card size="small" :bordered="false" class="costSetList-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="6" :sm="24">
  9. <a-form-item label="产品名称">
  10. <a-input id="costSetList-productName" v-model.trim="queryParam.product.name" allowClear placeholder="请输入产品名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="产品编码/原厂编码">
  15. <a-input id="costSetList-productCode" v-model.trim="queryParam.product.queryWord" allowClear placeholder="请输入产品编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="品牌">
  20. <ProductBrand id="costSeting-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品分类">
  25. <ProductType id="costSeting-productType" v-model="productType" @change="changeProductType"></ProductType>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="供应商名称">
  30. <a-input id="costSetList-productName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="审核状态">
  35. <v-select
  36. v-model="queryParam.auditState"
  37. ref="auditState"
  38. id="costSetList-auditState"
  39. code="SUPPLIER_PRODUCT_STATE"
  40. placeholder="请选择审核状态"
  41. allowClear></v-select>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  45. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="costSetList-refresh">查询</a-button>
  46. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="costSetList-reset">重置</a-button>
  47. <a-button
  48. style="margin-left: 10px"
  49. type="primary"
  50. class="button-warning"
  51. @click="handleExport"
  52. :disabled="disabled"
  53. :loading="exportLoading"
  54. v-if="$hasPermissions('B_costSetExportDetail')"
  55. id="costSetDetailList-export">导出明细</a-button>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. <!-- 操作按钮 -->
  60. <div class="table-operator">
  61. <a-button type="primary" v-if="$hasPermissions('B_costSetAddProduct')" class="button-error" @click="newProduct=true">新增</a-button>
  62. <a-button type="primary" v-if="$hasPermissions('B_costSetBatchImport')" class="button-warning" @click="handleBatchImport">批量导入</a-button>
  63. <a-button type="primary" v-if="$hasPermissions('B_costSetAudit')" class="button-warning" @click="handleBatchAudit">批量审核</a-button>
  64. </div>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable fixPagination"
  69. ref="table"
  70. :style="{ height: tableHeight+84.5+'px' }"
  71. size="small"
  72. :rowKey="(record) => record.supplierProductSn"
  73. rowKeyName="supplierProductSn"
  74. :row-selection="$hasPermissions('B_costSetAudit')?{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.auditState!=='WAIT' } }) }:null"
  75. @rowSelection="rowSelectionFun"
  76. :columns="columns"
  77. :data="loadData"
  78. :scroll="{ y: tableHeight }"
  79. :defaultLoadData="false"
  80. bordered>
  81. <!-- 产品分类 -->
  82. <template slot="productType" slot-scope="text, record">
  83. <span v-if="record.product&&(record.product.productTypeName2 || record.product.productTypeName3)">{{ record.product.productTypeName2 }} {{ record.product.productTypeName3 ? '>' : '' }} {{ record.product.productTypeName3 }}</span>
  84. <span v-else>--</span>
  85. </template>
  86. <!-- 操作 -->
  87. <template slot="action" slot-scope="text, record">
  88. <div>
  89. <a-button
  90. size="small"
  91. type="link"
  92. class="button-warning"
  93. v-if="record.auditState=='WAIT'&&$hasPermissions('B_costSetAudit')"
  94. @click="handleAudit([record.supplierProductSn])"
  95. >审核</a-button>
  96. <a-button
  97. size="small"
  98. type="link"
  99. class="button-warning"
  100. v-if="record.auditState!='WAIT'&&$hasPermissions('B_costSetting')"
  101. @click="handleCostSet(record)"
  102. >设置成本</a-button>
  103. </div>
  104. </template>
  105. </s-table>
  106. </a-spin>
  107. <!-- 新增 -->
  108. <addProductModal :openModal="newProduct" @close="newProduct=false" @ok="handleProductsOk" />
  109. <!-- 设置成本价 -->
  110. <SettingCost ref="settingCost" :openModal="openSetModal" @ok="$refs.table.refresh()" @close="openSetModal=false"></SettingCost>
  111. <!-- 导入产品 -->
  112. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="handleGuideOk" />
  113. </a-card>
  114. </template>
  115. <script>
  116. import { commonMixin } from '@/utils/mixin'
  117. import { STable, VSelect } from '@/components'
  118. import { hdExportExcel } from '@/libs/exportExcel'
  119. import ProductType from '@/views/common/productType.js'
  120. import ProductBrand from '@/views/common/productBrand.js'
  121. import addProductModal from './addProductModal.vue'
  122. import ImportGuideModal from './importGuideModal.vue'
  123. import SettingCost from './settingCost.vue'
  124. import { supplierProductList, supplierProductExportDetail, supplierProductUpdateAuditState, supplierProductNewBatchInsert } from '@/api/supplier'
  125. export default {
  126. name: 'costSettingList',
  127. mixins: [commonMixin],
  128. components: { STable, VSelect, ProductBrand, ProductType, addProductModal, SettingCost, ImportGuideModal },
  129. data () {
  130. return {
  131. spinning: false,
  132. exportLoading: false,
  133. advanced: true, // 高级搜索 展开/关闭
  134. openGuideModal: false,
  135. tableHeight: 0,
  136. queryParam: { // 查询条件
  137. supplierName: '',
  138. product: {
  139. name: '', // 产品名称
  140. queryWord: '', // 产品编码/原厂编码
  141. productBrandSn: undefined, // 产品品牌
  142. productTypeSn1: '', // 产品一级分类
  143. productTypeSn2: '', // 产品二级分类
  144. productTypeSn3: '' ,// 产品三级分类
  145. },
  146. auditState: undefined
  147. },
  148. disabled: false, // 查询、重置按钮是否可操作
  149. productType: [],
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. this.disabled = true
  153. this.spinning = true
  154. return supplierProductList(Object.assign(parameter, this.queryParam)).then(res => {
  155. let data
  156. if (res.status == 200) {
  157. data = res.data
  158. const no = (data.pageNo - 1) * data.pageSize
  159. for (var i = 0; i < data.list.length; i++) {
  160. data.list[i].no = no + i + 1
  161. }
  162. this.disabled = false
  163. }
  164. this.spinning = false
  165. return data
  166. })
  167. },
  168. rowSelectionInfo: null,
  169. newProduct: false,
  170. openSetModal: false
  171. }
  172. },
  173. computed: {
  174. columns () {
  175. const _this = this
  176. const arr = [
  177. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  178. { title: '产品名称', dataIndex: 'product.name', width: '12%', align: 'left', customRender: function (text) { return text || '--' } },
  179. { title: '产品编码', dataIndex: 'product.code', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  180. { title: '原厂编码', dataIndex: 'product.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '产品品牌', dataIndex: 'product.productBrandName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  182. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '12%', align: 'center' },
  183. { title: '供应商名称', dataIndex: 'supplierName', width: '12%', align: 'left', customRender: function (text) { return text || '--' } },
  184. { title: '审核时间', dataIndex: 'auditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '审核状态', dataIndex: 'auditStateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  186. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  187. ]
  188. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  189. arr.splice(7, 0, { title: '当前成本价', dataIndex: 'cost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  190. arr.splice(8, 0, { title: '变更成本价', dataIndex: 'modifyCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  191. }
  192. return arr
  193. }
  194. },
  195. methods: {
  196. // 表格选中项
  197. rowSelectionFun (obj) {
  198. this.rowSelectionInfo = obj || null
  199. },
  200. // 批量导入产品
  201. handleGuideOk (obj) {
  202. supplierProductNewBatchInsert(obj).then(res => {
  203. if (res.status == 200) {
  204. this.$refs.table.refresh(true)
  205. }
  206. })
  207. },
  208. // 重置
  209. resetSearchForm () {
  210. this.queryParam.supplierName = ''
  211. this.queryParam.product.name = ''
  212. this.queryParam.product.queryWord = ''
  213. this.queryParam.product.productBrandSn = undefined
  214. this.queryParam.product.productTypeSn1 = ''
  215. this.queryParam.product.productTypeSn2 = ''
  216. this.queryParam.product.productTypeSn3 = ''
  217. this.queryParam.auditState = undefined
  218. this.productType = []
  219. this.$refs.table.refresh(true)
  220. },
  221. // 产品分类 change
  222. changeProductType (val, opt) {
  223. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  224. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  225. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  226. },
  227. // 导出明细
  228. handleExport () {
  229. const _this = this
  230. const params = _this.queryParam
  231. _this.exportLoading = true
  232. _this.spinning = true
  233. hdExportExcel(supplierProductExportDetail, params, '成本设置明细', function () {
  234. _this.exportLoading = false
  235. _this.spinning = false
  236. })
  237. },
  238. // 新增成功
  239. handleProductsOk () {
  240. this.newProduct = false
  241. this.resetSearchForm()
  242. },
  243. // 批量导入
  244. handleBatchImport () {
  245. this.openGuideModal=true
  246. },
  247. // 批量审核
  248. handleBatchAudit () {
  249. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys
  250. if (!this.rowSelectionInfo || (row.length < 1)) {
  251. this.$message.warning('请在列表中进行勾选!')
  252. return false
  253. }
  254. this.handleAudit(row)
  255. },
  256. // 单个审核
  257. handleAudit (sn) {
  258. const _this = this
  259. this.$confirm({
  260. title: '提示',
  261. content: '确认要审核通过吗?',
  262. centered: true,
  263. closable: true,
  264. okText: '通过',
  265. cancelText: '不通过',
  266. onOk () {
  267. _this.auditOrder(sn, 'PASS')
  268. },
  269. onCancel (e) {
  270. if (!e.triggerCancel) {
  271. _this.auditOrder(sn, 'REJECT')
  272. }
  273. _this.$destroyAll()
  274. }
  275. })
  276. },
  277. auditOrder(sn,val){
  278. this.spinning = true
  279. supplierProductUpdateAuditState({
  280. auditState: val,
  281. supplierProductSnList: sn
  282. }).then(res => {
  283. if(res.status == 200){
  284. this.$refs.table.refresh(true)
  285. this.$refs.table.clearSelected()
  286. this.$message.info(res.message)
  287. }
  288. this.spinning = false
  289. })
  290. },
  291. // 成本设置
  292. handleCostSet (row) {
  293. this.openSetModal = true
  294. this.$refs.settingCost.setData(row)
  295. },
  296. pageInit () {
  297. const _this = this
  298. this.$nextTick(() => { // 页面渲染完成后的回调
  299. _this.setTableH()
  300. })
  301. },
  302. setTableH () {
  303. const tableSearchH = this.$refs.tableSearch.offsetHeight
  304. this.tableHeight = window.innerHeight - tableSearchH - 195
  305. }
  306. },
  307. watch: {
  308. advanced (newValue, oldValue) {
  309. const _this = this
  310. this.$nextTick(() => { // 页面渲染完成后的回调
  311. _this.setTableH()
  312. })
  313. },
  314. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  315. this.setTableH()
  316. }
  317. },
  318. mounted () {
  319. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  320. this.pageInit()
  321. this.resetSearchForm()
  322. }
  323. },
  324. activated () {
  325. // 如果是新页签打开,则重置当前页面
  326. if (this.$store.state.app.isNewTab) {
  327. this.pageInit()
  328. this.resetSearchForm()
  329. }
  330. // 仅刷新列表,不重置页面
  331. if (this.$store.state.app.updateList) {
  332. this.pageInit()
  333. this.$refs.table.refresh()
  334. }
  335. },
  336. beforeRouteEnter (to, from, next) {
  337. next(vm => {})
  338. }
  339. }
  340. </script>