list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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="associatedProduct-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="associatedProduct-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.state"
  37. ref="state"
  38. id="costSetList-state"
  39. code="FINANCIAL_RECEIVE_STATUS"
  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. id="costSetDetailList-export">导出明细</a-button>
  55. </a-col>
  56. </a-row>
  57. </a-form>
  58. <!-- 操作按钮 -->
  59. <div class="table-operator">
  60. <a-button type="primary" class="button-error" @click="newProduct=true">新增</a-button>
  61. <a-button type="primary" class="button-warning" @click="handleBatchImport">批量导入</a-button>
  62. <a-button type="primary" class="button-warning" @click="handleBatchAudit">批量审核</a-button>
  63. </div>
  64. </div>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable fixPagination"
  68. ref="table"
  69. :style="{ height: tableHeight+84.5+'px' }"
  70. size="small"
  71. :rowKey="(record) => record.id"
  72. :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: !record.id } }) }"
  73. @rowSelection="rowSelectionFun"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ y: tableHeight }"
  77. :defaultLoadData="false"
  78. bordered>
  79. <!-- 产品分类 -->
  80. <template slot="productType" slot-scope="text, record">
  81. <span v-if="record.product&&(record.product.productTypeName2 || record.product.productTypeName3)">{{ record.product.productTypeName2 }} {{ record.product.productTypeName3 ? '>' : '' }} {{ record.product.productTypeName3 }}</span>
  82. <span v-else>--</span>
  83. </template>
  84. <!-- 操作 -->
  85. <template slot="action" slot-scope="text, record">
  86. <a-button
  87. size="small"
  88. type="link"
  89. class="button-warning"
  90. @click="handleAudit(record)"
  91. >审核</a-button>
  92. <a-button
  93. size="small"
  94. type="link"
  95. class="button-warning"
  96. @click="handleCostSet(record)"
  97. >设置成本</a-button>
  98. </template>
  99. </s-table>
  100. </a-spin>
  101. <!-- 新增 -->
  102. <addProductModal :openModal="newProduct" @close="newProduct=false" @ok="handleProductsOk" />
  103. <!-- 设置成本价 -->
  104. <SettingCost ref="settingCost" :openModal="openSetModal" @ok="$refs.table.refresh()" @close="openSetModal=false"></SettingCost>
  105. </a-card>
  106. </template>
  107. <script>
  108. import { commonMixin } from '@/utils/mixin'
  109. import { STable, VSelect } from '@/components'
  110. import ProductType from '@/views/common/productType.js'
  111. import ProductBrand from '@/views/common/productBrand.js'
  112. import addProductModal from './addProductModal.vue'
  113. import SettingCost from './settingCost.vue'
  114. import { supplierProductList } from '@/api/supplier'
  115. export default {
  116. name: 'AssociatedProductDetailsList',
  117. mixins: [commonMixin],
  118. components: { STable, VSelect, ProductBrand, ProductType, addProductModal, SettingCost },
  119. data () {
  120. return {
  121. spinning: false,
  122. exportLoading: false,
  123. advanced: true, // 高级搜索 展开/关闭
  124. tableHeight: 0,
  125. queryParam: { // 查询条件
  126. supplierName: '',
  127. product: {
  128. name: '', // 产品名称
  129. queryWord: '', // 产品编码/原厂编码
  130. productBrandSn: undefined, // 产品品牌
  131. productTypeSn1: '', // 产品一级分类
  132. productTypeSn2: '', // 产品二级分类
  133. productTypeSn3: '' // 产品三级分类
  134. }
  135. },
  136. disabled: false, // 查询、重置按钮是否可操作
  137. productType: [],
  138. // 加载数据方法 必须为 Promise 对象
  139. loadData: parameter => {
  140. this.disabled = true
  141. this.spinning = true
  142. return supplierProductList(Object.assign(parameter, this.queryParam)).then(res => {
  143. let data
  144. if (res.status == 200) {
  145. data = res.data
  146. const no = (data.pageNo - 1) * data.pageSize
  147. for (var i = 0; i < data.list.length; i++) {
  148. data.list[i].no = no + i + 1
  149. }
  150. this.disabled = false
  151. }
  152. this.spinning = false
  153. return data
  154. })
  155. },
  156. rowSelectionInfo: null,
  157. newProduct: false,
  158. openSetModal: false
  159. }
  160. },
  161. computed: {
  162. columns () {
  163. const arr = [
  164. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  165. { title: '产品名称', dataIndex: 'product.name', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '产品编码', dataIndex: 'product.code', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '原厂编码', dataIndex: 'product.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '产品品牌', dataIndex: 'product.productBrandName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '12%', align: 'center' },
  170. { title: '供应商名称', dataIndex: 'supplierName', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '审核时间', dataIndex: 'creatDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  172. { title: '审核状态', dataIndex: 'state', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  173. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  174. ]
  175. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  176. arr.splice(7, 0, { title: '成本价(¥)', dataIndex: 'cost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  177. }
  178. return arr
  179. }
  180. },
  181. methods: {
  182. // 表格选中项
  183. rowSelectionFun (obj) {
  184. this.rowSelectionInfo = obj || null
  185. },
  186. // 重置
  187. resetSearchForm () {
  188. this.queryParam.supplierName = ''
  189. this.queryParam.product.name = ''
  190. this.queryParam.product.queryWord = ''
  191. this.queryParam.product.productBrandSn = undefined
  192. this.queryParam.product.productTypeSn1 = ''
  193. this.queryParam.product.productTypeSn2 = ''
  194. this.queryParam.product.productTypeSn3 = ''
  195. this.productType = []
  196. this.$refs.table.refresh(true)
  197. },
  198. // 产品分类 change
  199. changeProductType (val, opt) {
  200. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  201. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  202. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  203. },
  204. // 导出明细
  205. handleExport () {
  206. },
  207. // 新增成功
  208. handleProductsOk () {
  209. this.newProduct = false
  210. this.resetSearchForm()
  211. },
  212. // 批量导入
  213. handleBatchImport () {
  214. },
  215. // 批量审核
  216. handleBatchAudit () {
  217. },
  218. // 单个审核
  219. handleAudit (row) {
  220. const _this = this
  221. this.$confirm({
  222. title: '提示',
  223. content: '确认要审核通过吗?',
  224. centered: true,
  225. closable: true,
  226. okText: '通过',
  227. cancelText: '不通过',
  228. onOk () {
  229. // _this.auditOrder(row.allocateReturnSn, 'FINISH')
  230. },
  231. onCancel (e) {
  232. if (!e.triggerCancel) {
  233. // _this.auditOrder(row.allocateReturnSn, 'FINANCIAL_REJECT')
  234. }
  235. _this.$destroyAll()
  236. }
  237. })
  238. },
  239. // 成本设置
  240. handleCostSet (row) {
  241. this.openSetModal = true
  242. this.$refs.settingCost.setData(row)
  243. },
  244. pageInit () {
  245. const _this = this
  246. this.$nextTick(() => { // 页面渲染完成后的回调
  247. _this.setTableH()
  248. })
  249. },
  250. setTableH () {
  251. const tableSearchH = this.$refs.tableSearch.offsetHeight
  252. this.tableHeight = window.innerHeight - tableSearchH - 195
  253. }
  254. },
  255. watch: {
  256. advanced (newValue, oldValue) {
  257. const _this = this
  258. this.$nextTick(() => { // 页面渲染完成后的回调
  259. _this.setTableH()
  260. })
  261. },
  262. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  263. this.setTableH()
  264. }
  265. },
  266. mounted () {
  267. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  268. this.pageInit()
  269. this.resetSearchForm()
  270. }
  271. },
  272. activated () {
  273. // 如果是新页签打开,则重置当前页面
  274. if (this.$store.state.app.isNewTab) {
  275. this.pageInit()
  276. this.resetSearchForm()
  277. }
  278. // 仅刷新列表,不重置页面
  279. if (this.$store.state.app.updateList) {
  280. this.pageInit()
  281. this.$refs.table.refresh()
  282. }
  283. },
  284. beforeRouteEnter (to, from, next) {
  285. next(vm => {})
  286. }
  287. }
  288. </script>