list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div>
  3. <Toptitle title="费用单据">
  4. <Dropdown trigger="click" @on-click='handleTotalAll'>
  5. <Button type="primary">批量<Icon type="ios-arrow-down" style="padding-left:10px"/></Button>
  6. <DropdownMenu slot="list">
  7. <DropdownItem name='1'>审批</DropdownItem>
  8. <DropdownItem name='2'>删除</DropdownItem>
  9. <DropdownItem name='3'>打印</DropdownItem>
  10. </DropdownMenu>
  11. </Dropdown>
  12. </Toptitle>
  13. <div class="content">
  14. <Form class="form_content" :label-width='120'>
  15. <FormItem label='费用单据号:'>
  16. <Input class="form_item" placeholder="请搜索" v-model="searchData.cost_no" clearable/>
  17. </FormItem>
  18. <FormItem label='相关项目'>
  19. <Select class="form_item" v-model="searchData.project_name" filterable clearable>
  20. <Option v-for="(item,index) in projectTitleList" :key="index" :value="item.project_title" :label="item.project_title"></Option>
  21. </Select>
  22. </FormItem>
  23. <FormItem label='制单人:'>
  24. <Select class="form_item" v-model="searchData.crt_id" filterable clearable>
  25. <Option v-for="item in users" :key='item.id' :value="item.id" :label="item.nickname"/>
  26. </Select>
  27. </FormItem>
  28. <FormItem label='审批状态:'>
  29. <Select class="form_item" v-model="searchData.state" clearable>
  30. <Option :value="0" label="未审批"/>
  31. <Option :value="1" label='已审批'/>
  32. </Select>
  33. </FormItem>
  34. <FormItem label='审批人:'>
  35. <Select class="form_item" v-model="searchData.check_id" filterable clearable>
  36. <Option v-for="item in users" :key='item.id' :value="item.id" :label="item.nickname"/>
  37. </Select>
  38. </FormItem>
  39. <FormItem label='供应商'>
  40. <Select filterable clearable v-model="searchData.supply_id" >
  41. <Option v-for="(item,index) in suppliersList" :key="index" :value="item.id" :label="item.title"></Option>
  42. </Select>
  43. </FormItem>
  44. <FormItem label='创建时间:' style="width:100%">
  45. <DatePicker type="date" placeholder="年/月/日" class="form_item" v-model="searchData.start_time"></DatePicker>~
  46. <DatePicker type="date" placeholder="年/月/日" class="form_item" v-model="searchData.end_time"></DatePicker>
  47. </FormItem>
  48. <FormItem label='审批时间:'>
  49. <DatePicker type="date" placeholder="年/月/日" class="form_item" v-model="searchData.check_start_time"></DatePicker>~
  50. <DatePicker type="date" placeholder="年/月/日" class="form_item" v-model="searchData.check_end_time"></DatePicker>
  51. </FormItem>
  52. <FormItem :label-width='50'>
  53. <Button type="primary" @click="initData(searchData)">搜索</Button>
  54. </FormItem>
  55. </Form>
  56. <div class="before_table"><Button type="primary" @click="goPage(1)">新增</Button></div>
  57. <Table :data='tableData' :columns='tableColumns' border max-height='350' @on-selection-change='DataSelect' :loading='loading'>
  58. <template slot="set" slot-scope="{row}">
  59. <a style="margin-right:10px" v-show="row.state==1" @click='handelSet(row)'>弃审</a>
  60. <a style="margin-right:10px" v-show="row.state==0" @click='handelSet(row)'>审批</a>
  61. <a style="margin-right:10px" @click="goPage(3,row)">详情</a>
  62. <a @click="goPage(2,row)" style="margin-right:10px" v-show="row.state==0">编辑</a>
  63. <a style="margin-right:10px" v-show="row.state==0" @click="handleDel(row)">删除</a>
  64. <a>打印</a>
  65. </template>
  66. </Table>
  67. </div>
  68. <div class="pageSlotStyle">
  69. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  70. @on-page-size-change='changeSize'
  71. @on-change='changePage'
  72. :current='page_index'
  73. show-total
  74. :total="total"
  75. show-sizer
  76. :page-size='page_size' />
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. export default {
  82. data(){
  83. return{
  84. suppliersList:[],
  85. projectTitleList:[],
  86. loading:false,
  87. searchData:{
  88. cost_no:'',
  89. project_name:'',
  90. crt_id:'',
  91. state:"",
  92. check_id:'',
  93. supply_id:'',
  94. start_time:'',
  95. end_time:'',
  96. check_start_time:'',
  97. check_end_time:'',
  98. },
  99. chooseData:{},
  100. check_id:'',
  101. users:[],
  102. page_index:1,
  103. page_size:10,
  104. total:0,
  105. selectData:[],
  106. tableData:[],
  107. tableColumns:[
  108. {type:'selection',minWidth:80,align:'center'},
  109. {title:'费用单据号',align:'center',minWidth:140,key:'cost_no'},
  110. {title:'相关项目',align:'center',minWidth:150,key:'project_name'},
  111. {title:'供应商',align:'center',minWidth:150,key:'supply_title'},
  112. {title:'合计金额',align:'center',minWidth:120,key:'total_price'},
  113. {title:'制单人',align:'center',minWidth:120,key:'user_name'},
  114. {title:'创建时间',align:'center',minWidth:130,key:'crt_time',render:(h,params)=>{
  115. const {row} = params;
  116. return h('span',{},this.func.replaceDateNoHMS(row.crt_time))
  117. }},
  118. {title:'审批状态',align:'center',minWidth:140,key:'state',render:(h,params)=>{
  119. const {row} = params;
  120. const text = row.state==0?'未审批':'已审批';
  121. return h('span',{},text)
  122. }},
  123. {title:'审批人',align:'center',minWidth:120,key:'check_name'},
  124. {title:'审批时间',align:'center',minWidth:130,key:'check_time',render:(h,params)=>{
  125. const {row} = params;
  126. return h('span',{},this.func.replaceDateNoHMS(row.check_time))
  127. }},
  128. {title:'操作',align:'center',minWidth:300,key:'',slot:'set'}
  129. ]
  130. }
  131. },
  132. created(){
  133. //获取人员列表
  134. this.axios.get('/api/user').then(res=>{
  135. this.users = res.data.data
  136. })
  137. //获取项目名称
  138. this.axios.post('/api/cost_order_list').then(res=>{
  139. this.projectTitleList = res.data
  140. })
  141. // 获取供应商列表
  142. this.axios({ method: 'get', url: '/api/supply_list', }).then((res) => { this.suppliersList = res.data.data }).catch((err) => { });
  143. },
  144. mounted(){
  145. this.initData();
  146. },
  147. methods:{
  148. handleTotalAll(name){
  149. switch(name){
  150. case '1':
  151. if(this.selectData.length==0){
  152. return this.$Message.warning('请先选择数据!');
  153. };
  154. let ar = [];
  155. ar = this.selectData.filter(v=>{
  156. return v.state == 1;
  157. })
  158. if(ar.length!=0){
  159. return this.$Message.warning('数据中有不能审批的数据!')
  160. }
  161. this.confirmDelete({
  162. title:'确认',
  163. content: '确认审批么?',
  164. then: () => {
  165. let cost_no = [];
  166. this.selectData.forEach(v=>{
  167. cost_no.push(v.cost_no);
  168. })
  169. this.axios.post('/api/cost_check',{cost_no,state:0}).then(res=>{
  170. if(res.code==200){
  171. this.$Message.success(res.msg);
  172. this.initData(this.searchData);
  173. }
  174. })
  175. }})
  176. break;
  177. case '2':
  178. if(this.selectData.length==0){
  179. return this.$Message.warning('请先选择数据!');
  180. };
  181. let sureData = this.selectData.filter(v=>{
  182. return v.state == 1;
  183. });
  184. if(sureData.length!=0){
  185. return this.$Message.warning('已审批的数据不能删除!')
  186. }
  187. let cost = [];
  188. this.selectData.forEach(v=>{
  189. cost.push(v.cost_no);
  190. })
  191. this.confirmDelete({
  192. content: "确认删除么?",
  193. then: () => {
  194. this.axios
  195. .post("/api/cost_del", { cost_no:cost})
  196. .then((res) => {
  197. if (res.code == 200) {
  198. if(this.page_index!=1||this.tableData.length==1){
  199. this.page_index--;
  200. }
  201. this.$Message.success(res.msg);
  202. this.initData(this.searchData);
  203. }
  204. });
  205. },
  206. });
  207. break;
  208. case '3':
  209. if(this.selectData.length==0){
  210. return this.$Message.warning('请先选择数据!');
  211. };
  212. break;
  213. }
  214. },
  215. handleDel(row){
  216. this.confirmDelete({
  217. content: "确认删除么?",
  218. then: () => {
  219. this.axios
  220. .post("/api/cost_del", { cost_no:[row.cost_no]})
  221. .then((res) => {
  222. if (res.code == 200) {
  223. this.$Message.success(res.msg);
  224. if(this.page_index!=1||this.tableData.length==1){
  225. this.page_index--;
  226. }
  227. this.initData(this.searchData);
  228. }
  229. });
  230. },
  231. });
  232. },
  233. changePage(e){
  234. this.page_index = e;
  235. this.initData(this.searchData);
  236. },
  237. changeSize(e){
  238. this.page_size = e;
  239. this.page_index =1;
  240. this.initData(this.searchData);
  241. },
  242. handelSet(row){
  243. this.confirmDelete({
  244. title:'确认',
  245. content: `${row.state==0?'确定审批吗?':'确定弃审吗?'}`,
  246. then: () => {
  247. this.axios
  248. .post("/api/cost_check", { cost_no:[row.cost_no],state: row.state })
  249. .then((res) => {
  250. if (res.code == 200) {
  251. this.$Message.success(res.msg);
  252. this.initData(this.searchData);
  253. // this.undata_navData();
  254. }
  255. });
  256. },
  257. });
  258. },
  259. initData(row){
  260. let obj = {};
  261. if(row){
  262. obj = JSON.parse(JSON.stringify(row));
  263. obj.start_time = obj.start_time?Date.parse(obj.start_time).toString().slice(0,10):'';
  264. obj.end_time = obj.end_time?Date.parse(obj.end_time).toString().slice(0,10):'';
  265. obj.check_start_time = obj.check_start_time?Date.parse(obj.check_start_time).toString().slice(0,10):'';
  266. obj.check_end_time = obj.check_end_time?Date.parse(obj.check_end_time).toString().slice(0,10):'';
  267. }
  268. this.loading = true;
  269. this.axios.post('/api/cost_list',{...obj,page_size:this.page_size,page_index:this.page_index}).then(res=>{
  270. this.tableData = res.data.data;
  271. this.total = res.data.total;
  272. this.loading = false;
  273. })
  274. },
  275. DataSelect(e){
  276. this.selectData = e;
  277. },
  278. goPage(type,row){
  279. if(type==1){
  280. this.$router.push({path:'/cms/PurchasingManage/extraCosts/edit',query:{type}})
  281. }else{
  282. this.$router.push({path:'/cms/PurchasingManage/extraCosts/edit',query:{type,cost_no:row.cost_no,state:row.state}})
  283. }
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .content{
  290. height: 85%;
  291. overflow: auto;
  292. .form_content{
  293. margin-top:10px;
  294. display: flex;
  295. flex-wrap: wrap;
  296. .form_item{
  297. width:200px
  298. }
  299. }
  300. .before_table{
  301. display: flex;
  302. flex-direction: row-reverse;
  303. margin-bottom: 10px;
  304. }
  305. }
  306. .pageSlotStyle{
  307. text-align: center;
  308. margin-top:10px;
  309. }
  310. </style>