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