Supplier.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="8" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator">
  22. <a-button v-if="$auth('purchase-suppliers-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  23. <a-button style="margin-left: 8px" v-if="$auth('purchase-suppliers-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  24. </div>
  25. <s-table
  26. ref="table"
  27. size="default"
  28. rowKey="id"
  29. :columns="columns"
  30. :data="loadData"
  31. :alert="options.alert"
  32. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  33. :rowSelection="options.rowSelection"
  34. showPagination="auto"
  35. >
  36. <span slot="action" slot-scope="record">
  37. <template>
  38. <a @click="handleView(record)">查看</a>
  39. <operation-button
  40. v-if="$auth('purchase-suppliers-edit')"
  41. @click="handleEdit(record)"
  42. >修改</operation-button>
  43. <!-- <operation-button-->
  44. <!-- :type="1"-->
  45. <!-- @click="handleGoodsList(record.id)">供货清单</operation-button>-->
  46. <!-- <operation-button-->
  47. <!-- :type="1"-->
  48. <!-- @click="handleGoodsRecord(record.id)">供货记录</operation-button>-->
  49. </template>
  50. </span>
  51. </s-table>
  52. </div>
  53. <apply-form
  54. ref="baseApplyModal"
  55. @ok="handleOk"
  56. :supplyTypeMap="supplyTypeMap"
  57. :typeMap="typeMap"
  58. :statusMap="statusMap"
  59. :natureMap="natureMap"/>
  60. <base-form
  61. ref="baseModal"
  62. @ok="handleOk"
  63. :supplyTypeMap="supplyTypeMap"
  64. :typeMap="typeMap"
  65. :statusMap="statusMap"
  66. :natureMap="natureMap"/>
  67. <audit-form
  68. ref="auditModal"
  69. @ok="handleOk"
  70. :supplyTypeMap="supplyTypeMap"
  71. :typeMap="typeMap"
  72. :statusMap="statusMap"
  73. :natureMap="natureMap"/>
  74. <detail
  75. ref="detailModal"
  76. @ok="handleOk"
  77. :supplyTypeMap="supplyTypeMap"
  78. :typeMap="typeMap"
  79. :statusMap="statusMap"
  80. :natureMap="natureMap"/>
  81. <supplier-goods-list ref="supplierGoodsList" @ok="handleOk"></supplier-goods-list>
  82. <supplier-goods-record ref="supplierGoodsRecord" @ok="handleOk"></supplier-goods-record>
  83. </a-card>
  84. </template>
  85. <script>
  86. import { STable, Ellipsis } from '@/components'
  87. import BaseForm from './modules/BaseForm'
  88. import AuditForm from './modules/AuditForm'
  89. import ApplyForm from './modules/ApplyForm'
  90. import SupplierGoodsList from './SupplierGoodsList'
  91. import SupplierGoodsRecord from './SupplierGoodsRecord'
  92. import Detail from './modules/Detail'
  93. import { getSupplierPage, deleteSuppliers, fetchSupplier, exportSupplier } from '@/api/purchase/supplier'
  94. export default {
  95. name: 'SupplierList',
  96. components: {
  97. STable,
  98. Ellipsis,
  99. BaseForm,
  100. ApplyForm,
  101. AuditForm,
  102. SupplierGoodsList,
  103. SupplierGoodsRecord,
  104. Detail
  105. },
  106. data () {
  107. return {
  108. // 查询参数
  109. queryParam: {
  110. statusList: [2, 3, 98]
  111. },
  112. visible: true,
  113. supplyTypeMap: {},
  114. typeMap: {},
  115. statusMap: {},
  116. natureMap: {},
  117. // 表头
  118. columns: [
  119. {
  120. title: '序号',
  121. dataIndex: 'index',
  122. checked: true,
  123. width: 70,
  124. customRender: (text, record, index) => {
  125. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  126. }
  127. },
  128. // {
  129. // title: '账号',
  130. // dataIndex: 'account',
  131. // checked: true,
  132. // width: 100
  133. // },
  134. {
  135. title: '名称',
  136. dataIndex: 'name',
  137. checked: true,
  138. width: 150
  139. },
  140. {
  141. title: '类型',
  142. dataIndex: 'type',
  143. width: 120,
  144. checked: true,
  145. customRender: (text, record, index) => {
  146. return this.BaseTool.Table.customRenderMultiDictValue(this, text, record, this.typeMap)
  147. }
  148. },
  149. {
  150. title: '单位性质',
  151. width: 120,
  152. dataIndex: 'unitNature',
  153. customRender: (text, record, index) => {
  154. return this.BaseTool.Table.customRenderDictValue(this, text, record, this.typeMap)
  155. }
  156. },
  157. {
  158. title: '单位法人',
  159. dataIndex: 'legalPerson',
  160. width: 120
  161. },
  162. {
  163. title: '电话',
  164. dataIndex: 'phone',
  165. checked: true,
  166. width: 150
  167. },
  168. {
  169. title: '联系人',
  170. dataIndex: 'contactPerson',
  171. checked: true,
  172. width: 120
  173. },
  174. {
  175. title: '供货类别',
  176. dataIndex: 'supplyType',
  177. checked: true,
  178. width: 150,
  179. customRender: (text, record, index) => {
  180. return this.BaseTool.Table.customRenderMultiDictValue(this, text, record, this.supplyTypeMap)
  181. }
  182. },
  183. {
  184. title: '供货品牌',
  185. dataIndex: 'supplyBrand',
  186. checked: true,
  187. width: 150
  188. },
  189. {
  190. title: '经营范围',
  191. dataIndex: 'businessScope',
  192. checked: true,
  193. width: 200
  194. },
  195. {
  196. title: '邮箱',
  197. dataIndex: 'email',
  198. checked: true,
  199. width: 150
  200. },
  201. // {
  202. // title: '状态',
  203. // dataIndex: 'status',
  204. // width: 120,
  205. // checked: true,
  206. // customRender: (text, record, index) => {
  207. // return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  208. // this.DictCache.COLOR.SUPPLIER_STATUS, this.statusMap)
  209. // }
  210. // },
  211. {
  212. title: '申请时间',
  213. checked: true,
  214. dataIndex: 'applyTime',
  215. width: 180
  216. },
  217. {
  218. title: '操作',
  219. key: 'action',
  220. checked: true,
  221. width: '200px',
  222. fixed: 'right',
  223. align: 'center',
  224. scopedSlots: { customRender: 'action' }
  225. }
  226. ],
  227. // 下拉框map
  228. // 加载数据方法 必须为 Promise 对象
  229. loadData: parameter => {
  230. parameter = {
  231. ...parameter,
  232. ...this.queryParam,
  233. dataScope: {
  234. sortBy: 'desc',
  235. sortName: 'update_time'
  236. }
  237. }
  238. return getSupplierPage(Object.assign(parameter, this.queryParam))
  239. .then(res => {
  240. return res.data
  241. })
  242. },
  243. selectedRowKeys: [],
  244. selectedRows: [],
  245. options: {
  246. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  247. rowSelection: {
  248. selectedRowKeys: this.selectedRowKeys,
  249. onChange: this.onSelectChange
  250. }
  251. },
  252. optionAlertShow: false
  253. }
  254. },
  255. created () {
  256. // 下拉框map
  257. this.tableOption()
  258. this.supplyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_TYPE)
  259. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SUPPLIER_TYPE)
  260. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SUPPLIER_STATUS)
  261. this.natureMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SUPPLIER_NATURE)
  262. },
  263. methods: {
  264. tableOption () {
  265. if (!this.optionAlertShow) {
  266. this.options = {
  267. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  268. rowSelection: {
  269. selectedRowKeys: this.selectedRowKeys,
  270. onChange: this.onSelectChange,
  271. getCheckboxProps: record => ({
  272. props: {
  273. disabled: false,
  274. name: record.id
  275. }
  276. })
  277. }
  278. }
  279. this.optionAlertShow = true
  280. } else {
  281. this.options = {
  282. alert: false,
  283. rowSelection: null
  284. }
  285. this.optionAlertShow = false
  286. }
  287. },
  288. handleAdd () {
  289. this.visible = false
  290. this.$refs.baseApplyModal.base()
  291. },
  292. batchDelete (id) {
  293. let ids = []
  294. if (this.BaseTool.String.isBlank(id)) {
  295. const length = this.selectedRows.length
  296. if (length === 0) {
  297. this.$message.info('请选择要删除的记录')
  298. return
  299. }
  300. ids = this.selectedRows.map(item => item.id)
  301. } else {
  302. ids = [id]
  303. }
  304. deleteSuppliers(ids).then(res => {
  305. this.$message.info('删除成功')
  306. this.handleOk()
  307. this.$refs.table.clearSelected()
  308. })
  309. },
  310. handleGoodsList (id) {
  311. this.visible = false
  312. const modal = this.$refs.supplierGoodsList
  313. modal.base(id)
  314. },
  315. handleGoodsRecord (id) {
  316. this.visible = false
  317. const modal = this.$refs.supplierGoodsRecord
  318. modal.base(id)
  319. },
  320. handleEdit (record) {
  321. fetchSupplier({ id: record.id }).then(res => {
  322. this.visible = false
  323. const modal = this.$refs.baseModal
  324. modal.base(res.data)
  325. })
  326. },
  327. handleView (record) {
  328. fetchSupplier({ id: record.id }).then(res => {
  329. const modal = this.$refs.detailModal
  330. this.visible = false
  331. modal.base(res.data)
  332. })
  333. },
  334. handleOk () {
  335. this.visible = true
  336. this.$refs.table.refresh()
  337. },
  338. onSelectChange (selectedRowKeys, selectedRows) {
  339. this.selectedRowKeys = selectedRowKeys
  340. this.selectedRows = selectedRows
  341. },
  342. resetSearchForm () {
  343. this.queryParam = {
  344. statusList: [0, 1, 99]
  345. }
  346. this.$refs.table.refresh(true)
  347. },
  348. doExport () {
  349. const parameter = {
  350. ...this.queryParam
  351. }
  352. exportSupplier(parameter).then(file => {
  353. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  354. })
  355. },
  356. handleEnter () {
  357. this.$refs.table.refresh(true)
  358. }
  359. }
  360. }
  361. </script>