index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. ...(orderName.value ? { taskName: orderName.value } : {}),
  30. ...(orderName.value ? { contractName: orderName.value } : {}),
  31. deptId: getDeptId(),
  32. projectClassification: '2',
  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/ruiyingx/detail?id=' + item.id + `&type=${type.value}-detail`,
  47. });
  48. };
  49. const navigatorEdit = item => {
  50. uni.navigateTo({
  51. url: type.value === 'edit' ? '/pages/ruiyingx/edit?id=' + item.id : '/pages/ruiyingx/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('repairStatus').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('repairStatus').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.repairStatus }">{{
  132. constructionStatusDict[item.repairStatus]
  133. }}</span>
  134. </view>
  135. <view class="content-item">
  136. <span class="label">审批状态:</span>
  137. <span class="auditStatus" :class="`status-${item.auditStatus}`">{{
  138. approvalStatusDict[item.auditStatus]
  139. }}</span>
  140. </view>
  141. </view>
  142. <view class="footer">
  143. <button class="button" size="mini" type="primary" plain="true" @click="navigatorDetail(item)">
  144. {{ $t('operation.view') }}
  145. </button>
  146. <!-- 填写 -->
  147. <button v-show="showBtn(item)" class="button" size="mini" type="primary" @click="navigatorEdit(item)">
  148. {{ type === 'edit' ? $t('operation.fill') : $t('operation.approve') }}
  149. </button>
  150. </view>
  151. </view>
  152. </view>
  153. </z-paging>
  154. </template>
  155. <style scoped>
  156. .page {
  157. padding: 10px;
  158. }
  159. .top {
  160. height: 40px;
  161. background: #f3f5f9;
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. gap: 20px;
  166. }
  167. :deep(.mini-btn) {
  168. height: 38px !important;
  169. font-size: 16px !important;
  170. }
  171. .list {
  172. margin-top: 16px;
  173. display: flex;
  174. flex-direction: column;
  175. gap: 12px;
  176. .item {
  177. background-color: #fff;
  178. padding: 10px;
  179. border-radius: 8px;
  180. display: flex;
  181. flex-direction: column;
  182. gap: 10px;
  183. .header {
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-between;
  187. font-size: 16px;
  188. font-weight: 500;
  189. .fill-status {
  190. font-size: 14px;
  191. font-weight: 500;
  192. display: inline-flex;
  193. padding: 5px;
  194. border-radius: 4px;
  195. &.status-0 {
  196. color: #ff4d4f;
  197. background: rgba(255, 77, 79, 0.2);
  198. }
  199. &.status-2 {
  200. color: #4096ff;
  201. background: rgba(64, 150, 255, 0.2);
  202. }
  203. &.status-1 {
  204. color: #00c250;
  205. background: rgba(0, 194, 80, 0.2);
  206. }
  207. }
  208. }
  209. .content {
  210. display: flex;
  211. flex-direction: column;
  212. gap: 6px;
  213. .content-item {
  214. font-size: 14px;
  215. font-weight: 400;
  216. .label {
  217. display: inline-block;
  218. font-weight: 500;
  219. width: 70px;
  220. }
  221. .constructionStatus {
  222. font-size: 14px;
  223. font-weight: 500;
  224. display: inline-flex;
  225. padding: 5px;
  226. border-radius: 4px;
  227. color: #4096ff;
  228. background: rgba(64, 150, 255, 0.2);
  229. }
  230. .auditStatus {
  231. font-size: 14px;
  232. font-weight: 500;
  233. display: inline-flex;
  234. padding: 5px;
  235. border-radius: 4px;
  236. &.status-0 {
  237. color: #595959;
  238. background: rgba(89, 89, 89, 0.2);
  239. }
  240. &.status-30 {
  241. color: #ff4d4f;
  242. background: rgba(255, 77, 79, 0.2);
  243. }
  244. &.status-10 {
  245. color: #4096ff;
  246. background: rgba(64, 150, 255, 0.2);
  247. }
  248. &.status-20 {
  249. color: #00c250;
  250. background: rgba(0, 194, 80, 0.2);
  251. }
  252. }
  253. }
  254. }
  255. .footer {
  256. display: flex;
  257. justify-content: flex-end;
  258. align-items: center;
  259. gap: 0 12px;
  260. height: 32px;
  261. .button {
  262. margin: 0;
  263. }
  264. }
  265. }
  266. }
  267. </style>