deviceScreen.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view>
  3. <u-popup :show="show" closeOnClickOverlay mode="top" @close="closePopup">
  4. <view class="search_list">
  5. <u-form labelPosition="left" :model="form" labelWidth="180" labelAlign="left" class="baseForm">
  6. <!-- <u-form-item label="创建时间:" class="required-form" borderBottom prop="rangeDate">
  7. <uni-datetime-picker v-model="rangeDate" :border="true" :icon="false" type="daterange" />
  8. </u-form-item> -->
  9. <u-form-item label="使用单位:" class="required-form" borderBottom prop="postName">
  10. <!-- <u-input v-model="form.postId" placeholder="请选择" type="text" @click.stop="openDepartmentPicker" /> -->
  11. <view :style="{ color: form.postName ? 'black' : '#c0c4cc' }" class="assetType_box"
  12. @click="openDepartmentPicker">
  13. {{ form.postName ? form.postName : '请选择使用单位' }}
  14. </view>
  15. </u-form-item>
  16. </u-form>
  17. </view>
  18. <view class="operate_box rx-bc">
  19. <u-button size="small" class="u-reset-button" @click="reset">
  20. 重置
  21. </u-button>
  22. <u-button type="success" size="small" class="u-reset-button" @click="submit">
  23. 确定
  24. </u-button>
  25. </view>
  26. </u-popup>
  27. <ba-tree-picker ref="departmentPicker" :multiple="false" @select-change="departmentConfirm" title="选择领料部门"
  28. :localdata="departmentOption" valueKey="id" textKey="name" childrenKey="children" />
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. getWarehouseList,
  34. getProduceTreeByPid
  35. } from '@/api/warehouseManagement'
  36. import {
  37. post,
  38. get
  39. } from '@/utils/api.js'
  40. import DictSelection from "@/components/Dict/DictSelection.vue";
  41. import dictMxins from "@/mixins/dictMixins";
  42. import { orderTypeEnum, saleOrderProgressStatusEnum, reviewStatusEnum } from '@/enum/dict.js'
  43. import {
  44. listOrganizations
  45. } from '@/api/common'
  46. import {
  47. toTreeData
  48. } from '@/utils/utils.js'
  49. export default {
  50. mixins: [dictMxins],
  51. components: {
  52. DictSelection
  53. },
  54. props: ['type', 'postId', 'postName'],
  55. data() {
  56. return {
  57. show: false,
  58. rangeDate: [],
  59. form: {
  60. postId: '',
  61. postName: ''
  62. },
  63. orderTypeEnum,
  64. saleOrderProgressStatusEnum,
  65. reviewStatusEnum,
  66. departmentOption: []
  67. }
  68. },
  69. created() {
  70. this.initDeptData()
  71. },
  72. methods: {
  73. openDepartmentPicker() {
  74. this.$refs.departmentPicker._show()
  75. },
  76. // 部门列表
  77. async initDeptData() {
  78. let deptTreeList = await listOrganizations()
  79. this.departmentOption = toTreeData({
  80. data: deptTreeList,
  81. idField: 'id',
  82. parentIdField: 'parentId'
  83. })
  84. },
  85. departmentConfirm(data, name, allList) {
  86. console.log(data, name, allList)
  87. this.form.postId = data[0]
  88. this.form.postName = name
  89. },
  90. handleSaleTypeChange(val) {
  91. console.log(val)
  92. },
  93. open() {
  94. this.show = true
  95. for (let key of Object.keys(this.form)) {
  96. this.form[key] = this[key]
  97. }
  98. // if(this.createTimeStart && this.createTimeEnd) {
  99. // this.rangeDate = [this.createTimeStart, this.createTimeEnd]
  100. // } else {
  101. // this.setDefaultRangeDate()
  102. // }
  103. },
  104. setDefaultRangeDate() {
  105. const now = new Date()
  106. const year = now.getFullYear()
  107. const month = String(now.getMonth() + 1).padStart(2, '0')
  108. const day = String(now.getDate()).padStart(2, '0')
  109. const today = `${year}-${month}-${day}`
  110. if (this.type === 'year') {
  111. this.rangeDate = [`${year}-01-01`, today]
  112. } else if (this.type === 'month') {
  113. this.rangeDate = [`${year}-${month}-01`, today]
  114. }
  115. },
  116. closePopup() {
  117. this.show = false
  118. },
  119. reset() {
  120. this.form = {
  121. postId: '',
  122. postName: ''
  123. }
  124. this.rangeDate = [],
  125. this.$emit('succeed', this.form)
  126. this.closePopup()
  127. },
  128. submit() {
  129. // if(this.rangeDate.length) {
  130. // this.form.createTimeStart = this.rangeDate[0]
  131. // this.form.createTimeEnd = this.rangeDate[1]
  132. // }
  133. this.$emit('succeed', this.form)
  134. this.closePopup()
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .search_list {
  141. min-height: 100rpx;
  142. /deep/ .baseForm {
  143. padding: 0 20rpx;
  144. }
  145. }
  146. .operate_box {
  147. padding: 10rpx 32rpx;
  148. /deep/ .u-button {
  149. width: 40%;
  150. }
  151. }
  152. /deep/.baseForm {
  153. .u-form-item__body {
  154. padding: 4px !important;
  155. }
  156. .assetType_box {
  157. padding: 12rpx 18rpx;
  158. width: 100%;
  159. overflow: hidden;
  160. white-space: nowrap;
  161. text-overflow: ellipsis;
  162. font-size: 30rpx;
  163. }
  164. }
  165. </style>