list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="purchase_order">
  3. <Toptitle title="采购订单">
  4. <slot name="titleButton">
  5. <!-- <Button type="primary"
  6. @click="handleGoPage(1,'')"
  7. style="margin-right:10px;">新增</Button> -->
  8. <!-- <Button @click="handleCodeRule"
  9. type="primary"
  10. ghost
  11. style="margin-right:10px;">编码规则</Button> -->
  12. </slot>
  13. </Toptitle>
  14. <div class="content">
  15. <div class="purchase_order_search">
  16. <Form :label-width="100"
  17. :model="searchData">
  18. <FormItem label="订单号:" style="width:300px">
  19. <Input type="text"
  20. size="small"
  21. v-model="searchData.order_no"
  22. style="width: 150px"
  23. clearable
  24. placeholder="订单号" />
  25. </FormItem>
  26. <FormItem label="采购订单类型:" style="width:300px">
  27. <Select v-model="searchData.type_id"
  28. size="small"
  29. clearable
  30. filterable
  31. label-in-value
  32. style="width: 150px">
  33. <Option v-for="(sitem) in purchaseTypeList"
  34. :key="sitem.id"
  35. :label="sitem.title"
  36. :value="sitem.id">
  37. </Option>
  38. </Select>
  39. </FormItem>
  40. <FormItem label="供应商名称:" style="width:300px">
  41. <Input type="text"
  42. size="small"
  43. v-model="searchData.supply_title"
  44. style="width: 150px"
  45. clearable
  46. placeholder="供应商名称" />
  47. </FormItem>
  48. <FormItem label="订单状态:" style="width:300px">
  49. <Select v-model="searchData.lock"
  50. size="small"
  51. clearable
  52. style="width: 150px">
  53. <Option label='已关闭'
  54. :value='0' />
  55. <Option label='部分关闭'
  56. :value='1' />
  57. <Option label='正常'
  58. :value='2' />
  59. </Select>
  60. </FormItem>
  61. <FormItem label="制单人:" style="width:300px">
  62. <Select v-model="searchData.crt_id"
  63. size="small"
  64. clearable
  65. style="width: 150px">
  66. <Option v-for="(sitem) in userList"
  67. :key="sitem.id"
  68. :label="sitem.nickname"
  69. :value="sitem.id">
  70. </Option>
  71. </Select>
  72. </FormItem>
  73. <FormItem label="审批状态:" style="width:300px">
  74. <Select v-model="searchData.state"
  75. size="small"
  76. clearable
  77. style="width: 150px">
  78. <Option label='未审核'
  79. :value='0' />
  80. <Option label='已审核'
  81. :value='1' />
  82. </Select>
  83. </FormItem>
  84. <FormItem label="审批人:" style="width:300px">
  85. <Select v-model="searchData.check_id"
  86. size="small"
  87. clearable
  88. style="width: 150px">
  89. <Option v-for="(sitem) in userList"
  90. :key="sitem.id"
  91. :label="sitem.nickname"
  92. :value="sitem.id">
  93. </Option>
  94. </Select>
  95. </FormItem>
  96. <FormItem label="预计到货日期:" style="width:450px">
  97. <DatePicker type="date"
  98. size="small"
  99. style="width: 150px"
  100. placeholder="年/月/日"
  101. v-model="searchData.arrive_start_time"></DatePicker>
  102. ~
  103. <DatePicker type="date"
  104. size="small"
  105. style="width: 150px"
  106. placeholder="年/月/日"
  107. v-model="searchData.arrive_end_time"></DatePicker>
  108. </FormItem>
  109. <FormItem label="单据日期:" style="width:450px">
  110. <DatePicker type="date"
  111. size="small"
  112. style="width: 150px"
  113. placeholder="年/月/日"
  114. v-model="searchData.order_start_time"></DatePicker>
  115. ~
  116. <DatePicker type="date"
  117. size="small"
  118. style="width: 150px"
  119. placeholder="年/月/日"
  120. v-model="searchData.order_end_time"></DatePicker>
  121. </FormItem>
  122. <FormItem label="订单创建时间:" style="width:450px">
  123. <DatePicker type="date"
  124. size="small"
  125. style="width: 150px"
  126. placeholder="年/月/日"
  127. v-model="searchData.start_time"></DatePicker>
  128. ~
  129. <DatePicker type="date"
  130. size="small"
  131. style="width: 150px"
  132. placeholder="年/月/日"
  133. v-model="searchData.end_time"></DatePicker>
  134. </FormItem>
  135. <FormItem>
  136. <Button type="primary"
  137. @click="initData(searchData)"
  138. style="margin-right:10px;">搜索</Button>
  139. <Button type="primary"
  140. @click="handleGoPage(1,'')"
  141. style="margin-right:10px;">新增</Button>
  142. </FormItem>
  143. </Form>
  144. </div>
  145. <div class="purchase_order_content">
  146. <div class="purchase_order_content_table">
  147. <Table :columns="tableColumns"
  148. border
  149. :max-height="500"
  150. :data="historyTableData">
  151. <template slot="setSlot"
  152. slot-scope="{row,index}">
  153. <a style="margin:0 5px"
  154. @click="handleSet(6,row,index)">复制</a>
  155. <a style="margin:0 5px"
  156. @click="handleSet(2,row,index)">详情</a>
  157. <a style="margin:0 5px"
  158. v-if="!row.state==1||!row.state==2"
  159. @click="handleSet(3,row,index)">编辑</a>
  160. <a style="margin:0 5px"
  161. v-if="!row.state==1||!row.state==2"
  162. @click="handleSet(4,row,index)">删除</a>
  163. <a style="margin:0 5px"
  164. @click="handleSet(5,row,index)">{{row.state==0?'审批':'弃审'}}</a>
  165. </template>
  166. </Table>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="purchase_order_content_page">
  171. <Page :page-size-opts="[10, 20, 30, 40,100]"
  172. @on-page-size-change='changeSize'
  173. @on-change='changePage'
  174. :current='pageIndex'
  175. show-total
  176. :total="total"
  177. show-sizer
  178. :page-size='pageSize' />
  179. </div>
  180. </div>
  181. </template>
  182. <script>
  183. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  184. // 例如:import 《组件名称》 from '《组件路径》';
  185. export default {
  186. name: 'PurchasingOrderList',
  187. components: {
  188. },
  189. props: {},
  190. // import引入的组件需要注入到对象中才能使用
  191. data () {
  192. // 这里存放数据
  193. return {
  194. searchData: {
  195. order_no: '',
  196. project_title: '',
  197. supply_title: '',
  198. type_id: '',
  199. user_id: '',
  200. lock: '',
  201. state: '',
  202. start_time: '',
  203. end_time: '',
  204. arrive_start_time:'',
  205. arrive_end_time:'',
  206. order_start_time:'',
  207. order_end_time:'',
  208. },
  209. purchaseTypeList: [],
  210. tableColumns: [
  211. { title: '订单号', key: 'order_no', align: 'center', minWidth: 140 },
  212. { title: '采购订单类型', key: 'basics_purchase_title', align: 'center', minWidth: 140 },
  213. { title: '供应商名称', key: 'supply_title', align: 'center', minWidth: 140 },
  214. {
  215. title: '订单状态', key: 'lock', align: 'center', minWidth: 120,
  216. render: (h, params) => {
  217. const { row } = params
  218. const text = row.lock == 0 ? '已关闭' :row.lock == 1?'部分关闭':'正常'
  219. return h('span', {}, text)
  220. }
  221. },
  222. { title: '制单人', key: 'user_name', align: 'center', minWidth: 100 },
  223. {
  224. title: '审批状态', key: 'state', align: 'center', minWidth: 140,
  225. render: (h, params) => {
  226. const { row } = params
  227. const text = row.state == 0 ? '未审批' : '已审批'
  228. return h('span', {}, text)
  229. }
  230. },
  231. { title: '审批人', key: 'check_name', align: 'center', minWidth: 100 },
  232. {
  233. title: '预计到货日期', key: 'arrive_time', align: 'center', minWidth: 140,
  234. render: (h, params) => {
  235. const { row } = params
  236. return h('span', {}, this.func.replaceDateNoHMS(row.arrive_time))
  237. }
  238. },
  239. {
  240. title: '单据日期', key: 'order_time', align: 'center', minWidth: 140,
  241. render: (h, params) => {
  242. const { row } = params
  243. return h('span', {}, this.func.replaceDate(row.order_time).split(' ')[0]||'')
  244. }
  245. },
  246. {
  247. title: '订单创建时间', key: 'crt_time', align: 'center', minWidth: 170,
  248. render: (h, params) => {
  249. const { row } = params
  250. return h('span', {}, this.func.replaceDate(row.crt_time))
  251. }
  252. },
  253. { title: '操作', key: 'code', align: 'center', minWidth: 250, slot: 'setSlot' },
  254. ],
  255. tableData: [{}],
  256. historyTableData:[],
  257. pageIndex: 1,
  258. pageSize: 10,
  259. total: 0,
  260. userList: [],
  261. }
  262. },
  263. // 生命周期 - 创建完成(可以访问当前this实例)
  264. created () {
  265. // 获取采购类型
  266. this.axios({ method: 'get', url: '/api/basic_purchase_list',params:{type_id:2} }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
  267. // 获取操作员
  268. this.axios('/api/user').then(res => this.userList = res.data.data)
  269. },
  270. // 生命周期 - 挂载完成(可以访问DOM元素)
  271. mounted () {
  272. this.initData()
  273. },
  274. beforeRouteLeave (to, from, next) {
  275. console.log(to.path != '/cms/PurchasingManage/PurchasingOrder/edit');
  276. if (to.path != '/cms/PurchasingManage/PurchasingOrder/edit') {
  277. this.$destroy()
  278. }
  279. next();
  280. },
  281. beforeRouteEnter(to,from,next){
  282. next(vm =>{
  283. if(from.name === 'PurchasingOrderEdit'){
  284. vm.initData()
  285. }
  286. })
  287. },
  288. methods: {
  289. initData () {
  290. let obj = JSON.parse(JSON.stringify(this.searchData))
  291. obj.start_time = parseInt(new Date(obj.start_time).getTime() / 1000) || ''
  292. obj.end_time = parseInt(new Date(obj.end_time).getTime() / 1000) || ''
  293. obj.order_start_time = parseInt(new Date(obj.order_start_time).getTime() / 1000) || ''
  294. obj.order_end_time = parseInt(new Date(obj.order_end_time).getTime() / 1000) || ''
  295. obj.arrive_start_time = parseInt(new Date(obj.arrive_start_time).getTime() / 1000) || ''
  296. obj.arrive_end_time = parseInt(new Date(obj.arrive_end_time).getTime() / 1000) || ''
  297. this.axios({
  298. method: 'get',
  299. url: '/api/purchase_list',
  300. params: {
  301. ...obj,
  302. }
  303. }).then((res) => {
  304. this.tableData = res.data.data
  305. this.historyTableData = this.tableData.slice(0,this.pageSize)
  306. this.total = res.data.total
  307. }).catch((err) => { });
  308. },
  309. handleSet (type, row, index) {
  310. // 1新增 2详情 3编辑 4删除 5提交
  311. switch (type) {
  312. case 1:
  313. case 2:
  314. case 6:
  315. case 3:
  316. this.handleGoPage(type, row.order_no)
  317. break;
  318. case 4:
  319. this.$Modal.confirm({
  320. title: '确认删除?',
  321. content: '此操作无法恢复,请确认!',
  322. onOk: () => {
  323. this.axios({
  324. method: 'post',
  325. url: '/api/purchase_del',
  326. data: {
  327. order_no: row.order_no
  328. }
  329. }).then((res) => {
  330. this.$Message.success(res.msg)
  331. this.initData()
  332. }).catch((err) => { });
  333. },
  334. onCancel: () => { }
  335. })
  336. break;
  337. case 5:
  338. this.$Modal.confirm({
  339. title: '确认审核?',
  340. // content: '此操作无法恢复,请确认!',
  341. onOk: () => {
  342. this.axios({
  343. method: 'get',
  344. url: '/api/purchase_check',
  345. params: {
  346. order_no: row.order_no,
  347. // lock: row.lock,
  348. state: row.state==0?1:0,
  349. }
  350. }).then((res) => {
  351. this.$Message.success(res.msg)
  352. this.initData()
  353. }).catch((err) => { });
  354. },
  355. onCancel: () => { }
  356. })
  357. break;
  358. }
  359. },
  360. handleGoPage (type, order_no) {
  361. this.$router.push({
  362. path: '/cms/PurchasingManage/PurchasingOrder/edit',
  363. query: {
  364. type,
  365. order_no,
  366. }
  367. })
  368. },
  369. changeSize (e) {
  370. this.pageSize = e;
  371. this.initData()
  372. },
  373. changePage (index) {
  374. this.pageIndex = index;
  375. let _start = (index - 1)*this.pageSize;
  376. let _end = index * this.pageSize;
  377. // this.initData()
  378. this.historyTableData = this.tableData.slice(_start,_end)
  379. }
  380. },
  381. // 监听属性 类似于data概念
  382. computed: {
  383. },
  384. // 监控data中的数据变化
  385. watch: {},
  386. beforeCreate () { }, // 生命周期 - 创建之前
  387. beforeMount () { }, // 生命周期 - 挂载之前
  388. beforeUpdate () { }, // 生命周期 - 更新之前
  389. updated () { }, // 生命周期 - 更新之后
  390. beforeDestroy () { }, // 生命周期 - 销毁之前
  391. destroyed () { }, // 生命周期 - 销毁完成
  392. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  393. }
  394. </script>
  395. <style lang='scss' scoped>
  396. .purchase_order_search {
  397. padding-top: 20px;
  398. /deep/.ivu-form {
  399. display: flex;
  400. justify-content: flex-start;
  401. flex-wrap: wrap;
  402. }
  403. /deep/.ivu-form-item {
  404. display: inline-block;
  405. width: 250px;
  406. }
  407. }
  408. .purchase_order_content {
  409. border-top: 1px solid #f4f4f4;
  410. margin-top: 20px;
  411. .purchase_order_content_btn {
  412. display: flex;
  413. justify-content: flex-end;
  414. padding: 20px 0;
  415. }
  416. }
  417. .purchase_order_content_page {
  418. display: flex;
  419. justify-content: center;
  420. padding-top: 20px;
  421. }
  422. .content{
  423. overflow: auto;
  424. height: 650px;
  425. }
  426. </style>