MaterialRegistration.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <a-card :bordered="false" >
  3. <!-- 查询 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="12">
  8. <a-form-item label="设备名称">
  9. <a-input placeholder="输入设备名称查询" v-model="queryParam.name"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="12">
  13. <a-form-item label="购买日期">
  14. <a-date-picker
  15. style="width: 100%"
  16. placeholder="请选择购买日期"
  17. v-model="buyTime"
  18. @change="onEndDateChange"
  19. />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="12">
  23. <a-form-item label="状态">
  24. <a-input placeholder="输入设备状态查询" v-model="queryParam.type"></a-input>
  25. </a-form-item>
  26. </a-col>
  27. <template v-if="toggleSearchStatus">
  28. <a-col :md="6" :sm="12">
  29. <a-form-item label="编号">
  30. <a-input placeholder="输入编号查询" v-model="queryParam.code"></a-input>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="8">
  35. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  36. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  37. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  38. <a @click="handleToggleSearch" style="margin-left: 8px">
  39. {{ toggleSearchStatus ? '收起' : '展开' }}
  40. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  41. </a>
  42. </span>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <!-- 操作按钮区域 -->
  48. <div class="table-operator" style="border-top: 5px">
  49. <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>
  50. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete()">
  51. <a-button type="primary" icon="plus">删除</a-button>
  52. </a-popconfirm>
  53. </div>
  54. <!-- table区域-begin -->
  55. <div>
  56. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  57. <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  58. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  59. </div>
  60. <a-table
  61. ref="table"
  62. bordered
  63. size="middle"
  64. rowKey="id"
  65. :columns="columns"
  66. :dataSource="dataSource"
  67. :pagination="pagination"
  68. :scroll="{x: 1500 , y: 500 }"
  69. :loading="loading"
  70. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  71. @change="handleTableChange">
  72. <span slot="operation" slot-scope="text, record">
  73. <a @click="handleEdit(record)">编辑</a>
  74. <a-divider type="vertical" />
  75. <a @click="handleDetail(record)">详情</a>
  76. </span>
  77. </a-table>
  78. </div>
  79. <!-- 新增框 -->
  80. <add-material-registration ref='AddMaterialRegistration' @close="handleCl"></add-material-registration>
  81. <detail-material-registration ref="DetailMaterialRegistration"></detail-material-registration>
  82. </a-card>
  83. </template>
  84. <script>
  85. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  86. import AddMaterialRegistration from './modules/AddMaterialRegistration'
  87. import DetailMaterialRegistration from './modules/DetailMaterialRegistration'
  88. import JEllipsis from '@/components/jeecg/JEllipsis'
  89. import {
  90. managementList,
  91. managementAdd,
  92. managementEdit,
  93. enterpriseEDelete,
  94. managementListA,
  95. managementListB,
  96. managementListC
  97. } from '@api/oa/cd-material-registration'
  98. import moment from 'moment'
  99. export default {
  100. name: "MaterialRegistration",
  101. mixins: [JeecgListMixin],
  102. components: {
  103. AddMaterialRegistration,
  104. DetailMaterialRegistration,
  105. moment,
  106. JEllipsis
  107. },
  108. data() {
  109. let ellipsis = (v, l = 10) => <j-ellipsis value={v} length={l} />
  110. return {
  111. queryParam:{ //查询条件
  112. },
  113. buyTime:'',
  114. selectedRowKeysL:[],
  115. // 表头
  116. columns:[
  117. {
  118. title: '编号',
  119. align: "center",
  120. dataIndex: 'code',
  121. width: 120
  122. },
  123. {
  124. title: '设备名称',
  125. align: "center",
  126. dataIndex: 'name',
  127. width: 120
  128. },
  129. {
  130. title: '型号',
  131. align: "center",
  132. dataIndex: 'model',
  133. width: 120
  134. },
  135. {
  136. title: '购买日期',
  137. align: "center",
  138. dataIndex: 'buyTime',
  139. width: 120
  140. },
  141. {
  142. title: '购买数量',
  143. align: "center",
  144. dataIndex: 'buyNum',
  145. width: 120
  146. },
  147. {
  148. title: '单位',
  149. align: "center",
  150. dataIndex: 'unit',
  151. width: 120
  152. },
  153. {
  154. title: '购买金额',
  155. align: "center",
  156. dataIndex: 'amount',
  157. width: 120
  158. },
  159. {
  160. title: '使用者',
  161. align: "center",
  162. dataIndex: 'useId',
  163. width: 120
  164. },
  165. {
  166. title: '状态',
  167. align: "center",
  168. dataIndex: 'type',
  169. width: 120
  170. },
  171. {
  172. title: '供货方',
  173. align: "center",
  174. dataIndex: 'supply',
  175. width: 120
  176. },
  177. {
  178. title: '备注',
  179. align: "center",
  180. dataIndex: 'remarks',
  181. width: 120,
  182. customRender: (t) => ellipsis(t),
  183. },
  184. {
  185. title: '来源',
  186. align: "center",
  187. dataIndex: 'source',
  188. width: 120
  189. },
  190. {
  191. title: '操作',
  192. align: "center",
  193. dataIndex: 'operation',
  194. scopedSlots: { customRender: 'operation' },
  195. width: 120
  196. },
  197. ],
  198. pagination:{ }
  199. }
  200. },
  201. computed: {
  202. },
  203. created(){
  204. this.getData()
  205. },
  206. methods: {
  207. // 查询
  208. searchQuery(){
  209. this.getData()
  210. },
  211. //重置
  212. searchReset(){
  213. this.queryParam ={}
  214. this.buyTime = ''
  215. this.getData()
  216. },
  217. // 获取数据
  218. getData(){
  219. this.$nextTick(() => {
  220. managementList(this.queryParam).then(res => {
  221. // console.log('>>>>', this.queryParam)
  222. if (res.success) {
  223. this.dataSource =res.result.records
  224. this.pagination = {
  225. total: res.result.total,
  226. current: res.result.current,
  227. pageSize: res.result.size
  228. }
  229. }else{
  230. this.$message.error(res.message);
  231. }
  232. })
  233. })
  234. },
  235. onEndDateChange(value){
  236. this.queryParam.buyTime =moment(value).format('YYYY-MM-DD');
  237. },
  238. // 删除
  239. handleDelete(){
  240. if(this.selectedRowKeys.length == 0){
  241. this.$message.error("请选择要删除的数据");
  242. }else{
  243. var id = this.selectedRowKeys.toString()
  244. enterpriseEDelete({ids:id}).then(res => {
  245. // console.log('>>>>', this.queryParam)
  246. if (res.success) {
  247. this.$message.success('删除成功');
  248. this.getData()
  249. }else{
  250. this.$message.error(res.message);
  251. }
  252. })
  253. }
  254. },
  255. // 添加
  256. handleAdd(){
  257. this.$refs.AddMaterialRegistration.visible = true
  258. },
  259. //编辑
  260. async handleEdit(record){
  261. await managementListA({id:record.id}).then(res => {
  262. // console.log('>>>>', this.queryParam)
  263. if (res.success) {
  264. this.$refs.AddMaterialRegistration.formState = res.result
  265. this.$refs.AddMaterialRegistration.formState.buyTime = moment( res.result.buyTime)
  266. }else{
  267. this.$message.error(res.message);
  268. }
  269. })
  270. await managementListB({id:record.id}).then(res => {
  271. // console.log('>>>>', this.queryParam)
  272. if (res.success) {
  273. res.result.map(item =>[
  274. item.state = '0'
  275. ])
  276. this.$refs.AddMaterialRegistration.List = res.result
  277. }else{
  278. this.$message.error(res.message);
  279. }
  280. })
  281. await managementListC({id:record.id}).then(res => {
  282. // console.log('>>>>', this.queryParam)
  283. if (res.success) {
  284. res.result.map(item =>[
  285. item.state = '0'
  286. ])
  287. this.$refs.AddMaterialRegistration.List1 = res.result
  288. this.$refs.AddMaterialRegistration.visible = true
  289. this.$refs.AddMaterialRegistration.defult = 'edit'
  290. }else{
  291. this.$message.error(res.message);
  292. }
  293. })
  294. },
  295. //详情
  296. async handleDetail(record){
  297. await managementListA({id:record.id}).then(res => {
  298. // console.log('>>>>', this.queryParam)
  299. if (res.success) {
  300. this.$refs.DetailMaterialRegistration.formState = res.result
  301. }else{
  302. this.$message.error(res.message);
  303. }
  304. })
  305. await managementListB({id:record.id}).then(res => {
  306. // console.log('>>>>', this.queryParam)
  307. if (res.success) {
  308. this.$refs.DetailMaterialRegistration.List = res.result
  309. }else{
  310. this.$message.error(res.message);
  311. }
  312. })
  313. await managementListC({id:record.id}).then(res => {
  314. // console.log('>>>>', this.queryParam)
  315. if (res.success) {
  316. this.$refs.DetailMaterialRegistration.List1 = res.result
  317. this.$refs.DetailMaterialRegistration.visible = true
  318. this.$refs.DetailMaterialRegistration.visible = true
  319. }else{
  320. this.$message.error(res.message);
  321. }
  322. })
  323. },
  324. onSelectChange(keys,rows){
  325. this.selectedRowKeys = keys;
  326. this.selectedRows = rows;
  327. },
  328. // 分页变化时触发
  329. handleTableChange(pagination, filters, sorter) {
  330. this.queryParam.pageNo = pagination.current
  331. this.getData()
  332. },
  333. handleCl(){
  334. this.getData()
  335. }
  336. }
  337. }
  338. </script>
  339. <style scoped>
  340. @import '~@assets/less/common.less'
  341. </style>