containeroperate.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div style="margin-top: 42px;">
  3. <transition appear enter-active-class="animated fadeIn">
  4. <q-table class="my-sticky-header-column-table shadow-24" :data="table_list" row-key="id" :separator="separator"
  5. :loading="loading" :columns="columns" hide-bottom :pagination.sync="pagination" no-data-label="No data"
  6. no-results-label="No data you want" :table-style="{ height: height }" flat bordered>
  7. <template v-slot:header-cell="props">
  8. <q-th :props="props" @dblclick="handleHeaderDblClick(props.col)">
  9. <!-- 为特定列添加下拉选择器 -->
  10. <template v-if="['bound_department'].includes(props.col.name)">
  11. <q-select
  12. dense
  13. outlined
  14. v-model="filterModels[props.col.name]"
  15. :options="getFilterOptions(props.col.name)"
  16. option-label="label"
  17. option-value="value"
  18. emit-value
  19. map-options
  20. clearable
  21. @input="handleFilterChange"
  22. style="min-width: 120px"
  23. >
  24. <template v-slot:prepend>
  25. <span class="text-caption">{{ props.col.label }}</span>
  26. </template>
  27. </q-select>
  28. </template>
  29. <template v-else>
  30. {{ props.col.label }}
  31. </template>
  32. </q-th>
  33. </template>
  34. <template v-slot:top>
  35. <q-btn-group push>
  36. <q-btn :label="$t('refresh')" icon="refresh" @click="reFresh()">
  37. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[10, 10]"
  38. content-style="font-size: 12px">{{ $t('refreshtip') }}</q-tooltip>
  39. </q-btn>
  40. </q-btn-group>
  41. <q-space />
  42. <div class="flex items-center">
  43. <div class="q-mr-md">{{ $t("download_center.createTime") }}</div>
  44. <q-input readonly outlined dense v-model="createDate2" :placeholder="interval">
  45. <template v-slot:append>
  46. <q-icon name="event" class="cursor-pointer">
  47. <q-popup-proxy ref="qDateProxy" transition-show="scale" transition-hide="scale">
  48. <q-date v-model="createDate1" range>
  49. <div class="row items-center justify-end q-gutter-sm">
  50. <q-btn :label="$t('index.cancel')" color="primary" flat v-close-popup />
  51. <q-btn :label="$t('index.clear')" color="primary" @click="createDate2 = ''; createDate1 = '';"
  52. v-close-popup />
  53. </div>
  54. </q-date>
  55. </q-popup-proxy>
  56. </q-icon>
  57. </template>
  58. </q-input>
  59. <q-btn-group push class="q-ml-md">
  60. </q-btn-group>
  61. <q-input outlined rounded dense debounce="300" color="primary" v-model="filter" :placeholder="$t('search')"
  62. @input="getSearchList()" @keyup.enter="getSearchList()">
  63. <template v-slot:append>
  64. <q-icon name="search" @click="getSearchList()" />
  65. </template>
  66. </q-input>
  67. </div>
  68. </template>
  69. <template v-slot:body="props">
  70. <q-tr :props="props">
  71. <template >
  72. <q-td key="document_date" :props="props">{{ props.row.batch_detail.bound_list.bound_date }}</q-td>
  73. </template>
  74. <template >
  75. <q-td key="document_number" :props="props">{{ props.row.batch_detail.bound_list.bound_code }}</q-td>
  76. </template>
  77. <template >
  78. <q-td key="document_type" :props="props">{{ props.row.batch_detail.bound_list.bound_code_type }}</q-td>
  79. </template>
  80. <template >
  81. <q-td key="business_type" :props="props">{{ props.row.batch_detail.bound_list.bound_bs_type }}</q-td>
  82. </template>
  83. <template >
  84. <q-td key="iout_type" :props="props">{{ props.row.batch_detail.bound_list.bound_type }}</q-td>
  85. </template>
  86. <template >
  87. <q-td key="department" :props="props">{{ props.row.batch_detail.bound_list.bound_department }}</q-td>
  88. </template>
  89. <template >
  90. <q-td key="warehouse_code" :props="props">{{ props.row.batch_detail.bound_batch.warehouse_code }}</q-td>
  91. </template>
  92. <template >
  93. <q-td key="warehouse_name" :props="props">{{ props.row.batch_detail.bound_batch.warehouse_name }}</q-td>
  94. </template>
  95. <template >
  96. <q-td key="goods_code" :props="props">{{ props.row.batch_detail.bound_batch.goods_code }}</q-td>
  97. </template>
  98. <template >
  99. <q-td key="goods_desc" :props="props">{{ props.row.batch_detail.bound_batch.goods_desc }}</q-td>
  100. </template>
  101. <template >
  102. <q-td key="goods_std" :props="props">{{ props.row.batch_detail.bound_batch.goods_std }}</q-td>
  103. </template>
  104. <template >
  105. <q-td key="goods_batch" :props="props">{{ props.row.container_detail.batch.bound_number }}</q-td>
  106. </template>
  107. <template >
  108. <q-td key="in_batch" :props="props">{{ props.row.container_detail.batch.goods_code}}</q-td>
  109. </template>
  110. <template >
  111. <q-td key="out_batch" :props="props">{{ props.row.batch_detail.bound_batch.out_batch }}</q-td>
  112. </template>
  113. <template >
  114. <q-td key="goods_unit" :props="props">{{ props.row.batch_detail.bound_batch.goods_unit }}</q-td>
  115. </template>
  116. <template >
  117. <q-td key="goods_in" :props="props">{{ props.row.batch_detail.bound_batch.goods_in }}</q-td>
  118. </template>
  119. <template >
  120. <q-td key="goods_out" :props="props">{{ props.row.batch_detail.bound_list.goods_out }}</q-td>
  121. </template>
  122. <template >
  123. <q-td key="goods_notes" :props="props">{{ props.row.task_wcs.message}}</q-td>
  124. </template>
  125. <template >
  126. <q-td key="creator" :props="props">{{ props.row.container_detail.creater}}</q-td>
  127. </template>
  128. </q-tr>
  129. </template>
  130. </q-table>
  131. </transition>
  132. <template>
  133. <div v-show="max !== 0" class="q-pa-lg flex flex-center">
  134. <div>{{ total }} </div>
  135. <q-pagination v-model="current" color="black" :max="max" :max-pages="6" boundary-links
  136. @click="getSearchList(current); paginationIpt = current" />
  137. <div>
  138. <input v-model="paginationIpt" @blur="changePageEnter" @keyup.enter="changePageEnter"
  139. style="width: 60px; text-align: center" />
  140. </div>
  141. </div>
  142. <div v-show="max === 0" class="q-pa-lg flex flex-center">
  143. <q-btn flat push color="dark" :label="$t('no_data')"></q-btn>
  144. </div>
  145. </template>
  146. </div>
  147. </template>
  148. <router-view />
  149. <script>
  150. import { getauth, postauth, putauth, deleteauth } from 'boot/axios_request'
  151. import { date, exportFile, LocalStorage } from 'quasar'
  152. export default {
  153. name: 'PageTask',
  154. data() {
  155. return {
  156. createDate1: '',
  157. createDate2: '',
  158. date_range: '',
  159. proxyDate: '',
  160. date: '',
  161. goods_code: '',
  162. goods_desc: '',
  163. openid: '',
  164. login_name: '',
  165. authin: '0',
  166. searchUrl: '',
  167. pathname: 'container/task/',
  168. pathname_previous: '',
  169. pathname_next: '',
  170. separator: 'cell',
  171. loading: false,
  172. height: '',
  173. viewForm: false,
  174. table_list: [],
  175. columns: [
  176. { name: 'document_date', required: true, label: '单据日期', align: 'left', field: 'document_date' },
  177. { name: 'document_number', label: '单据编号', field: 'document_number', align: 'center' },
  178. { name: 'document_type', label: '单据类型', field: 'document_type', align: 'center' },
  179. { name: 'business_type', label: '业务类型', field: 'business_type', align: 'center' },
  180. { name: 'iout_type', label: '出入库类型', field: 'iout_type', align: 'center' },
  181. { name: 'department', label: '部门', field: 'department', align: 'center' },
  182. { name: 'warehouse_code', label: '仓库编码', field: 'warehouse_code', align: 'center' },
  183. { name: 'warehouse_name', label: '仓库名称', field: 'warehouse_name', align: 'center' },
  184. { name: 'goods_code', label: '存货编码', field: 'goods_code', align: 'center' },
  185. { name: 'goods_desc', label: '存货', field: 'goods_desc', align: 'center' },
  186. { name: 'goods_std', label: '规格型号', field: 'goods_std', align: 'center' },
  187. { name: 'goods_batch', label: '批号', field: 'goods_batch', align: 'center' },
  188. { name: 'in_batch', label: '入库批号', field: 'in_batch', align: 'center' },
  189. { name: 'out_batch', label: '出库批号', field: 'out_batch', align: 'center' },
  190. { name: 'goods_unit', label: '计量单位', field: 'goods_unit', align: 'center' },
  191. { name: 'goods_in', label: '本期入库', field: 'goods_in', align: 'center' },
  192. { name: 'goods_out', label: '本期出库', field: 'goods_out', align: 'center' },
  193. { name: 'goods_notes', label: '备注', field: 'goods_notes', align: 'center' },
  194. { name: 'creator', label: '创建人', field: 'creator', align: 'center' },
  195. ],
  196. filter: '',
  197. pagination: {
  198. page: 1,
  199. rowsPerPage: 11
  200. },
  201. current: 1,
  202. max: 0,
  203. total: 0,
  204. paginationIpt: 1,
  205. current: 1,
  206. filterModels: {
  207. bound_department: null
  208. },
  209. filterdata: {},
  210. activeSearchField: '',
  211. activeSearchLabel: ''
  212. }
  213. },
  214. computed: {
  215. interval() {
  216. return this.$t('download_center.start') + ' - ' + this.$t('download_center.end')
  217. }
  218. },
  219. methods: {
  220. // 处理过滤变化
  221. handleFilterChange () {
  222. this.pagination.page = 1
  223. this.getSearchList(1)
  224. },
  225. handleHeaderDblClick (column) {
  226. // 排除不需要搜索的列
  227. if (['detail', 'action'].includes(column.name)) return
  228. this.activeSearchField = column.field
  229. this.activeSearchLabel = column.label
  230. // 弹出搜索对话框
  231. this.$q
  232. .dialog({
  233. title: `搜索${column.label}`,
  234. message: `请输入${column.label}的搜索条件`,
  235. prompt: {
  236. model: '',
  237. type: 'text'
  238. },
  239. cancel: true,
  240. persistent: true
  241. })
  242. .onOk((data) => {
  243. // 执行搜索
  244. this.executeColumnSearch(column.field, data)
  245. })
  246. .onCancel(() => {
  247. this.activeSearchField = ''
  248. this.activeSearchLabel = ''
  249. })
  250. },
  251. // 执行列搜索
  252. executeColumnSearch (field, value) {
  253. // 构建搜索参数
  254. if (
  255. field === 'type' ||
  256. field === 'audit_status' ||
  257. field === 'save_status' ||
  258. field === 'bound_status'
  259. ) {
  260. const searchParams = {
  261. [field]: value
  262. }
  263. // 清除其他搜索条件
  264. this.filter = ''
  265. this.date_range = ''
  266. // 执行搜索
  267. this.getList({
  268. ...searchParams,
  269. page: 1
  270. })
  271. // 重置激活的搜索字段
  272. this.activeSearchField = ''
  273. this.activeSearchLabel = ''
  274. } else {
  275. const searchParams = {
  276. [field + '__icontains']: value
  277. }
  278. // 清除其他搜索条件
  279. this.filter = ''
  280. this.date_range = ''
  281. // 执行搜索
  282. this.getList({
  283. ...searchParams,
  284. page: 1
  285. })
  286. this.filterdata = searchParams
  287. this.$q.notify({
  288. message: `已搜索 ${this.activeSearchLabel} 含有 "${value}" 的结果`,
  289. icon: 'search',
  290. color: 'positive'
  291. })
  292. // // 重置激活的搜索字段
  293. this.activeSearchField = ''
  294. this.activeSearchLabel = ''
  295. }
  296. },
  297. getList (params = {}) {
  298. var _this = this
  299. _this.loading = true
  300. // 合并基础参数
  301. const baseParams = {
  302. page: _this.current,
  303. page_size: _this.pagination.rowsPerPage
  304. }
  305. // 创建URLSearchParams处理参数
  306. const queryParams = new URLSearchParams({
  307. ...baseParams,
  308. ...params
  309. })
  310. console.log(queryParams)
  311. // 过滤空值参数
  312. Array.from(queryParams.entries()).forEach(([key, value]) => {
  313. if (value === '' || value === null || value === undefined) {
  314. queryParams.delete(key)
  315. }
  316. })
  317. getauth(`${_this.pathname}?${queryParams}`)
  318. .then((res) => {
  319. _this.table_list = res.results
  320. _this.total = res.count
  321. _this.max = Math.ceil(res.count / _this.pagination.rowsPerPage) || 0
  322. _this.pathname_previous = res.previous
  323. _this.pathname_next = res.next
  324. })
  325. .catch((err) => {
  326. _this.$q.notify({
  327. message: err.detail,
  328. icon: 'close',
  329. color: 'negative'
  330. })
  331. })
  332. .finally(() => {
  333. _this.loading = false
  334. })
  335. },
  336. changePageEnter() {
  337. if (Number(this.paginationIpt) < 1) {
  338. this.current = 1
  339. this.paginationIpt = 1
  340. } else if (Number(this.paginationIpt) > this.max) {
  341. this.current = this.max
  342. this.paginationIpt = this.max
  343. } else {
  344. this.current = Number(this.paginationIpt)
  345. }
  346. this.getSearchList(this.current)
  347. },
  348. // 带搜索条件加载
  349. getSearchList (page = 1) {
  350. this.current = page
  351. this.paginationIpt = page
  352. // 构建过滤参数
  353. const filterParams = {}
  354. for (const [key, value] of Object.entries(this.filterModels)) {
  355. if (value !== null && value !== '') {
  356. filterParams[key] = value
  357. }
  358. }
  359. this.getList({
  360. number__icontains: this.filter,
  361. document_date__range: this.date_range,
  362. ...filterParams ,// 添加过滤条件
  363. ...this.filterdata, // 添加其他过滤条件
  364. })
  365. },
  366. getListPrevious() {
  367. var _this = this
  368. if (LocalStorage.has('auth')) {
  369. getauth(_this.pathname_previous, {})
  370. .then(res => {
  371. _this.table_list = res.results
  372. _this.pathname_previous = res.previous
  373. _this.pathname_next = res.next
  374. })
  375. .catch(err => {
  376. _this.$q.notify({
  377. message: err.detail,
  378. icon: 'close',
  379. color: 'negative'
  380. })
  381. })
  382. } else {
  383. }
  384. },
  385. getListNext() {
  386. var _this = this
  387. if (LocalStorage.has('auth')) {
  388. getauth(_this.pathname_next, {})
  389. .then(res => {
  390. _this.table_list = res.results
  391. _this.pathname_previous = res.previous
  392. _this.pathname_next = res.next
  393. })
  394. .catch(err => {
  395. _this.$q.notify({
  396. message: err.detail,
  397. icon: 'close',
  398. color: 'negative'
  399. })
  400. })
  401. }
  402. },
  403. reFresh () {
  404. var _this = this
  405. this.filterdata = {}
  406. this.filterModels = {
  407. bound_department: null
  408. }
  409. _this.getSearchList()
  410. },
  411. updateProxy() {
  412. var _this = this
  413. _this.proxyDate = _this.date
  414. }
  415. },
  416. created() {
  417. var _this = this
  418. if (LocalStorage.has('openid')) {
  419. _this.openid = LocalStorage.getItem('openid')
  420. } else {
  421. _this.openid = ''
  422. LocalStorage.set('openid', '')
  423. }
  424. if (LocalStorage.has('login_name')) {
  425. _this.login_name = LocalStorage.getItem('login_name')
  426. } else {
  427. _this.login_name = ''
  428. LocalStorage.set('login_name', '')
  429. }
  430. if (LocalStorage.has('auth')) {
  431. const timeStamp = Date.now()
  432. const formattedString = date.formatDate(timeStamp, 'YYYY/MM/DD')
  433. _this.date = formattedString
  434. console.log(_this.date)
  435. _this.authin = '1'
  436. _this.getList()
  437. } else {
  438. _this.authin = '0'
  439. }
  440. },
  441. mounted() {
  442. var _this = this
  443. if (_this.$q.platform.is.electron) {
  444. _this.height = String(_this.$q.screen.height - 290) + 'px'
  445. } else {
  446. _this.height = _this.$q.screen.height - 290 + '' + 'px'
  447. }
  448. },
  449. updated() { },
  450. destroyed() { },
  451. // 在 watch 或方法中添加调试代码
  452. watch: {
  453. createDate1(val) {
  454. if (val) {
  455. if (val.to) {
  456. this.createDate2 = `${val.from} - ${val.to}`
  457. this.date_range = `${val.from},${val.to} `
  458. // this.downloadhUrl = this.pathname + 'filelist/?' + 'document_date__range=' + this.date_range
  459. } else {
  460. this.createDate2 = `${val}`
  461. this.dateArray = val.split('/')
  462. this.searchUrl = this.pathname + '?' + 'document_date__year=' + this.dateArray[0] + '&' + 'document_date__month=' + this.dateArray[1] + '&' + 'document_date__day=' + this.dateArray[2]
  463. // this.downloadhUrl = this.pathname + 'filelist/?' + 'document_date__year=' + this.dateArray[0] + '&' + 'document_date__month=' + this.dateArray[1] + '&' + 'document_date__day=' + this.dateArray[2]
  464. }
  465. this.date_range = this.date_range.replace(/\//g, '-')
  466. this.getSearchList()
  467. this.$refs.qDateProxy.hide()
  468. }
  469. else {
  470. this.createDate2 = ''
  471. this.date_range = ''
  472. this.getSearchList()
  473. }
  474. }
  475. }
  476. }
  477. </script>
  478. <style scoped>
  479. /* 添加在 <style> 中 */
  480. .q-date__calendar-item--selected {
  481. transition: all 0.3s ease;
  482. background-color: #1976d2 !important;
  483. }
  484. .q-date__range {
  485. background-color: rgba(25, 118, 210, 0.1);
  486. }
  487. </style>