index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <script setup>
  2. import { onShow, onLoad } from '@dcloudio/uni-app';
  3. import { ref, reactive, nextTick } from 'vue';
  4. import dayjs from 'dayjs';
  5. import { getRuiHenReportPage } from '@/api/ruihen';
  6. import { useDataDictStore } from '@/store/modules/dataDict';
  7. import { getDeptId } from '@/utils/auth';
  8. const dictStore = useDataDictStore();
  9. const fillStatusDict = reactive({});
  10. const approvalStatusDict = reactive({
  11. 0: '待提交',
  12. 10: '待审批',
  13. 20: '审批通过',
  14. 30: '审批拒绝',
  15. });
  16. const constructionStatusDict = reactive({});
  17. const placeholderStyle = ref('color:#797979;font-weight:500;font-size:16px');
  18. const inputStyles = reactive({
  19. backgroundColor: '#FFFFFF',
  20. color: '#797979',
  21. });
  22. const orderName = ref('');
  23. const paging = ref(null);
  24. const dataList = ref([]);
  25. const queryList = (pageNo, pageSize) => {
  26. getRuiHenReportPage({
  27. pageNo,
  28. pageSize,
  29. ...(orderName.value ? { taskName: orderName.value } : {}),
  30. ...(orderName.value ? { contractName: orderName.value } : {}),
  31. deptId: getDeptId(),
  32. })
  33. .then(res => {
  34. paging.value.complete(res.data.list);
  35. })
  36. .catch(() => {
  37. paging.value.complete(false);
  38. });
  39. };
  40. const searchList = () => {
  41. paging.value.reload();
  42. };
  43. const navigatorDetail = item => {
  44. uni.navigateTo({
  45. url: '/pages/ruihen/detail?id=' + item.id + `&type=${type.value}-detail`,
  46. });
  47. };
  48. const navigatorEdit = item => {
  49. uni.navigateTo({
  50. url: type.value === 'edit' ? '/pages/ruihen/edit?id=' + item.id : '/pages/ruihen/approval?id=' + item.id,
  51. });
  52. };
  53. const formatDate = time => {
  54. return dayjs(time).format('YYYY-MM-DD');
  55. };
  56. const formatTime = time => {
  57. return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
  58. };
  59. const type = ref('edit');
  60. onLoad(option => {
  61. type.value = option.type || 'edit';
  62. });
  63. onShow(() => {
  64. if (dictStore.dataDict.length <= 0) {
  65. dictStore.loadDataDictList().then(() => {
  66. dictStore.getStrDictOptions('operation_fill_order_status').map(item => {
  67. fillStatusDict[item.value] = item.label;
  68. });
  69. dictStore.getStrDictOptions('constructionStatus').map(item => {
  70. constructionStatusDict[item.value] = item.label;
  71. });
  72. });
  73. } else {
  74. dictStore.getStrDictOptions('operation_fill_order_status').map(item => {
  75. fillStatusDict[item.value] = item.label;
  76. });
  77. dictStore.getStrDictOptions('constructionStatus').map(item => {
  78. constructionStatusDict[item.value] = item.label;
  79. });
  80. }
  81. nextTick(() => {
  82. searchList();
  83. });
  84. });
  85. const showBtn = item => {
  86. if (type.value === 'edit') return item.status === 0;
  87. else return item.auditStatus === 10;
  88. };
  89. </script>
  90. <template>
  91. <z-paging class="page" ref="paging" v-model="dataList" @query="queryList">
  92. <template #top>
  93. <view class="top">
  94. <uni-easyinput
  95. v-model="orderName"
  96. :styles="inputStyles"
  97. :placeholderStyle="placeholderStyle"
  98. :placeholder="$t('operation.searchText')">
  99. </uni-easyinput>
  100. <button class="mini-btn" type="primary" size="mini" @click="searchList">
  101. {{ $t('operation.search') }}
  102. </button>
  103. </view>
  104. </template>
  105. <view class="list">
  106. <view class="item" v-for="(item, index) in dataList" :key="index">
  107. <view class="header">
  108. <span class="create-time">{{ item.createTime ? formatDate(item.createTime) : '' }}</span>
  109. <span class="fill-status" :class="`status-${item.status}`">{{ fillStatusDict[item.status] }}</span>
  110. </view>
  111. <view class="content">
  112. <view class="content-item">
  113. <span class="label">日期:</span>
  114. <span>{{ item.createTime ? formatTime(item.createTime) : '' }}</span>
  115. </view>
  116. <view class="content-item">
  117. <span class="label">项目:</span>
  118. <span>{{ item.contractName }}</span>
  119. </view>
  120. <view class="content-item">
  121. <span class="label">任务:</span>
  122. <span>{{ item.taskName }}</span>
  123. </view>
  124. <view class="content-item">
  125. <span class="label">施工队伍:</span>
  126. <span>{{ item.deptName }}</span>
  127. </view>
  128. <view class="content-item">
  129. <span class="label">施工状态:</span>
  130. <span :class="{ constructionStatus: item.constructionStatus }">{{
  131. constructionStatusDict[item.constructionStatus]
  132. }}</span>
  133. </view>
  134. <view class="content-item">
  135. <span class="label">审批状态:</span>
  136. <span class="auditStatus" :class="`status-${item.auditStatus}`">{{
  137. approvalStatusDict[item.auditStatus]
  138. }}</span>
  139. </view>
  140. </view>
  141. <view class="footer">
  142. <button class="button" size="mini" type="primary" plain="true" @click="navigatorDetail(item)">
  143. {{ $t('operation.view') }}
  144. </button>
  145. <!-- 填写 -->
  146. <button v-show="showBtn(item)" class="button" size="mini" type="primary" @click="navigatorEdit(item)">
  147. {{ type === 'edit' ? $t('operation.fill') : $t('operation.approve') }}
  148. </button>
  149. </view>
  150. </view>
  151. </view>
  152. </z-paging>
  153. </template>
  154. <style scoped>
  155. .page {
  156. padding: 10px;
  157. }
  158. .top {
  159. height: 40px;
  160. background: #f3f5f9;
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. gap: 20px;
  165. }
  166. :deep(.mini-btn) {
  167. height: 38px !important;
  168. font-size: 16px !important;
  169. }
  170. .list {
  171. margin-top: 16px;
  172. display: flex;
  173. flex-direction: column;
  174. gap: 12px;
  175. .item {
  176. background-color: #fff;
  177. padding: 10px;
  178. border-radius: 8px;
  179. display: flex;
  180. flex-direction: column;
  181. gap: 10px;
  182. .header {
  183. display: flex;
  184. align-items: center;
  185. justify-content: space-between;
  186. font-size: 16px;
  187. font-weight: 500;
  188. .fill-status {
  189. font-size: 14px;
  190. font-weight: 500;
  191. display: inline-flex;
  192. padding: 5px;
  193. border-radius: 4px;
  194. &.status-0 {
  195. color: #ff4d4f;
  196. background: rgba(255, 77, 79, 0.2);
  197. }
  198. &.status-2 {
  199. color: #4096ff;
  200. background: rgba(64, 150, 255, 0.2);
  201. }
  202. &.status-1 {
  203. color: #00c250;
  204. background: rgba(0, 194, 80, 0.2);
  205. }
  206. }
  207. }
  208. .content {
  209. display: flex;
  210. flex-direction: column;
  211. gap: 6px;
  212. .content-item {
  213. font-size: 14px;
  214. font-weight: 400;
  215. .label {
  216. display: inline-block;
  217. font-weight: 500;
  218. width: 70px;
  219. }
  220. .constructionStatus {
  221. font-size: 14px;
  222. font-weight: 500;
  223. display: inline-flex;
  224. padding: 5px;
  225. border-radius: 4px;
  226. color: #4096ff;
  227. background: rgba(64, 150, 255, 0.2);
  228. }
  229. .auditStatus {
  230. font-size: 14px;
  231. font-weight: 500;
  232. display: inline-flex;
  233. padding: 5px;
  234. border-radius: 4px;
  235. &.status-0 {
  236. color: #595959;
  237. background: rgba(89, 89, 89, 0.2);
  238. }
  239. &.status-30 {
  240. color: #ff4d4f;
  241. background: rgba(255, 77, 79, 0.2);
  242. }
  243. &.status-10 {
  244. color: #4096ff;
  245. background: rgba(64, 150, 255, 0.2);
  246. }
  247. &.status-20 {
  248. color: #00c250;
  249. background: rgba(0, 194, 80, 0.2);
  250. }
  251. }
  252. }
  253. }
  254. .footer {
  255. display: flex;
  256. justify-content: flex-end;
  257. align-items: center;
  258. gap: 0 12px;
  259. height: 32px;
  260. .button {
  261. margin: 0;
  262. }
  263. }
  264. }
  265. }
  266. </style>