list.vue 11 KB

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