list.vue 11 KB

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