bzkf30 1 anno fa
parent
commit
9d9d89d9fb

+ 161 - 7
src/pages/equipmentPurchase/index.vue

@@ -1,13 +1,167 @@
-<template>
-  <div>设备申购</div>
-</template>
+<script setup>
+import { closeToast, showConfirmDialog, showFailToast, showSuccessToast } from 'vant'
+import { userInfo } from "~/store/user";
+
+const router = useRouter();
+
+const list = ref([])
+const loading = ref(false)
+const finished = ref(false)
+let page = 1
+const param = $ref({
+  keyword: "",
+  xhs_zcmc: "",
+  xhs_zcfl: "",
+  xhs_spzt: "",
+  xhs_xwhtl: ""
+});
+function onLoad() {
+  loading.value = true
+  request({
+    url: '/xdhq/hqgl_sbsg/index',
+    data: {
+      page,
+      limit: 20,
+      ...param,
+    },
+  }).then((res) => {
+    const data = res.data
+    list.value = [...list.value, ...data.page_data]
+    finished.value = data.total_page === page
+    page++
+    loading.value = false
+  })
+}
+
+function onClickSearch() {
+  reGetList()
+}
+function dropItemChange() {
+  reGetList()
+}
+const itemRef = ref(null)
+function onConfirm() {
+  itemRef.value.toggle()
+  reGetList()
+}
+function reGetList() {
+  page = 1
+  list.value = []
+  finished.value = false
+  onLoad()
+}
 
-<script>
-export default {
+const statusOption = $ref([{ text: '状态', value: '' }, { text: '待审批', value: '1' }, { text: '通过', value: '2' }, { text: '不通过', value: '3' }]);
+const discussOption = $ref([{ text: '校务会讨论', value: '' }, { text: '是', value: '1' }, { text: '否', value: '2' }]);
 
+function handleAdd() {
+  router.push({
+    path: '/equipmentPurchase/purchase'
+  });
+}
+
+
+let sh_id = $ref("");
+let auditShow = $ref(false);
+let auditCheck = $ref("");
+function handleAudit(xhs_id) {
+  auditCheck = "";
+  auditShow = true;
+  sh_id = xhs_id;
+}
+function onBeforeClose(action) {
+  if (action === "confirm") {
+    auditConfirm();
+  } else {
+    auditShow = false;
+  }
+}
+async function auditConfirm() {
+  if (!auditCheck) {
+    showFailToast("请选择是否通过!");
+  } else {
+    let obj = {
+      xhs_id: sh_id,
+      xdhq_hqgl_sbsg: {
+        xhs_spzt: auditCheck
+      }
+    }
+    let { code } = await request({ url: '/xdhq/hqgl_sbsg/edit', data: obj });
+    if (code == 1) {
+      showSuccessToast('审核完成!');
+      auditShow = false;
+      reGetList();
+    }
+  }
 }
 </script>
 
-<style>
+<template>
+  <div class="index">
+    <van-search v-model="param.keyword" :clearable="false" show-action placeholder="请输入搜索关键词" @search="onClickSearch">
+      <template #action>
+        <div @click="onClickSearch">
+          搜索
+        </div>
+      </template>
+    </van-search>
+    <van-dropdown-menu>
+      <van-dropdown-item ref="itemRef" title="资产分类">
+        <van-cell-group inset>
+          <van-field v-model="param.xhs_zcfl" placeholder="请输入资产分类" />
+        </van-cell-group>
+        <div style="padding: 5px 16px;">
+          <van-button type="primary" block round @click="onConfirm">
+            确认
+          </van-button>
+        </div>
+      </van-dropdown-item>
+      <van-dropdown-item v-model="param.xhs_spzt" :options="statusOption" @change="dropItemChange" />
+      <van-dropdown-item v-model="param.xhs_xwhtl" :options="discussOption" @change="dropItemChange" />
+    </van-dropdown-menu>
+    <van-cell style="padding-top: 0 !important;">
+      <van-button class="w-full" type="primary" size="small" @click="handleAdd">设备申购</van-button>
+    </van-cell>
+    <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
+      <van-cell v-for="item in list" :key="item">
+        <template #title>
+          <span>{{ `${item.xhs_zcmc}` }}</span>
+          <span class="text-12px ml-15px">资产分类:{{ `${item.xhs_zcfl}` }}</span>
+        </template>
+        <template #value>
+          <van-button class="check" :disabled="item.xhs_spzt_option_k !== '1' || item.xhs_spr !== userInfo.user_realname" type="primary" @click="handleAudit(item.xhs_id)">审核</van-button>
+        </template>
+        <template #label>
+          <div class="flex text-black space-x-15px">
+            <div><span>单价:{{ item.xhs_zcdj }}</span></div>
+            <div><span>数量:{{ item.xhs_sl }}</span></div>
+            <div><span>总价:{{ item.xhs_zj }}</span></div>
+          </div>
+          <div class="flex text-black space-x-15px">
+            <div><span>审批人:{{ item.xhs_spr }}</span></div>
+            <div><span>状态:{{ item.xhs_spzt }}</span></div>
+            <div><span>校务会讨论:{{ item.xhs_xwhtl }}</span></div>
+          </div>
+        </template>
+      </van-cell>
+    </van-list>
+
+    <van-dialog v-model:show="auditShow" title="审核" show-cancel-button class="pl-30px" :before-close="onBeforeClose">
+      <van-radio-group class="my-20px" v-model="auditCheck" direction="horizontal">
+        <van-radio name="2">通过</van-radio>
+        <van-radio name="3">不通过</van-radio>
+      </van-radio-group>
+    </van-dialog>
+  </div>
+</template>
 
-</style>
+<style lang="scss" scoped>
+:deep(.van-list .van-cell__value) {
+  position: absolute;
+  right: 15px;
+}
+:deep(.van-button.check) {
+  padding: 3px 8px;
+  height: unset;
+}
+</style>

+ 183 - 0
src/pages/equipmentPurchase/purchase.vue

@@ -0,0 +1,183 @@
+<template>
+  <div class="index">
+    <div class="text-center leading-80px">设备申购</div>
+    <van-cell style="padding-top: 0 !important;">
+      <van-button type="primary" size="small" @click="handleAdd">添加设备</van-button>
+    </van-cell>
+    <van-form @submit="onSubmit">
+      <van-cell-group inset>
+        <van-cell v-for="(item, index) in addFormData" :key="index">
+          <van-field v-model="item.xhs_zcmc" name="资产名称" label="资产名称" placeholder="资产名称" :rules="[{ required: true, message: '请填写资产名称' }]" />
+          <van-field v-model="item.xhs_ggxh" name="规格型号" label="规格型号" placeholder="规格型号" />
+          <van-field v-model="item.xhs_zcfl" is-link readonly label="资产分类" placeholder="资产分类" :rules="[{ required: true, message: '请选择资产分类' }]" @click="show = true" />
+          <van-popup v-model:show="show" round position="bottom">
+            <van-cascader v-model="cascaderValue" title="请选择资产分类" :field-names="fieldNames" :options="options" @close="show = false" @finish="onFinish($event, item)" />
+          </van-popup>
+          <van-field v-model="item.xhs_zcpc" name="资产批次" label="资产批次" placeholder="资产批次" />
+          <van-field v-model="item.xhs_zcdj" name="单价" label="单价" placeholder="单价" type="number" @blur="handleZjChange(item)" :rules="[{ required: true, message: '请填写单价' }]" />
+          <van-field v-model="item.xhs_sl" name="数量" label="数量" placeholder="数量" type="number" @blur="handleZjChange(item)" :rules="[{ required: true, message: '请填写数量' }]" />
+          <van-field v-model="item.xhs_dw" name="数量单位" label="数量单位" placeholder="数量单位" :rules="[{ required: true, message: '请填写数量单位' }]" />
+          <van-field v-model="item.xhs_ssbm" name="所属部门" label="所属部门" placeholder="所属部门" />
+          <van-field v-model="item.xhs_zj" name="总价" label="总价" disabled />
+          <van-field v-model="item.xhs_gmsj" is-link readonly name="购买时间" label='购买时间' placeholder="购买时间" @click="showDatePicker=true" />
+          <van-popup v-model:show="showDatePicker" position="bottom">
+            <van-date-picker v-model="currentDate" :min-date="minDate" @confirm="onDateConfirm($event, item)" @cancel="showDatePicker=false" />
+          </van-popup>
+          <div class="text-right">
+            <van-button v-if="addFormData.length>1" type="danger" size="small" @click="handleRemove(index)">删除设备</van-button>
+          </div>
+        </van-cell>
+        <van-cell>
+          <van-field v-model="totalMoney" name="合计" label="合计" disabled />
+          <template v-if="splc_info === null">
+            <div class="text-red-400 text-lg text-center py-2">暂未设置审批流程!</div>
+          </template>
+          <template v-else>
+            <div v-if="!dialogForm_Data_add_extend.xhs_spr" class="text-red-400 text-lg text-center py-2">无符合的流程!</div>
+            <template v-else>
+              <van-field v-model="dialogForm_Data_add_extend.xhs_spr" name="input" label="审批人" disabled />
+              <van-field name="radio" label="校务会讨论" disabled>
+                <template #input>
+                  <van-radio-group disabled v-model="dialogForm_Data_add_extend.xhs_xwhtl" direction="horizontal">
+                    <van-radio name="1">是</van-radio>
+                    <van-radio name="2">否</van-radio>
+                  </van-radio-group>
+                </template>
+              </van-field>
+            </template>
+          </template>
+        </van-cell>
+      </van-cell-group>
+      <div style="margin: 16px;">
+        <van-button round block type="primary" native-type="submit">
+          提交
+        </van-button>
+      </div>
+    </van-form>
+  </div>
+</template>
+
+<script setup>
+import { computed } from "vue";
+import { closeToast, showConfirmDialog, showFailToast, showSuccessToast } from 'vant'
+const router = useRouter();
+const route = router.currentRoute.value
+const xsxk_id = route.query.xsxk_id
+
+initSplcInfo();
+
+let splc_info = $ref(null);
+async function initSplcInfo() {
+  let { code, data } = await request({ url: '/xdhq/hqgl_splcsz/index' });
+  if (code == 1) {
+    if (data.page_data[0]) {
+      splc_info = data.page_data[0];
+    }
+  }
+}
+
+const totalMoney = computed(() => addFormData.reduce((t, { xhs_zj }) => t += parseFloat(xhs_zj ?? '0'), 0))
+
+const dialogForm_Data_add_extend = computed(() => {
+  if (splc_info === null) {
+    return {}
+  } else {
+    const arr = JSON.parse(splc_info.xhsl_sz);
+    for (const iterator of arr) {
+      const { sign, val_1, val_2, spr, jwhtl } = iterator;
+      if (
+        (sign === '1' && totalMoney.value < val_1) ||
+        (sign === '2' && totalMoney.value >= val_1 && totalMoney.value < val_2) ||
+        (sign === '3' && totalMoney.value >= val_2)
+      ) {
+        return {
+          xhs_spr: spr,
+          xhs_xwhtl: jwhtl
+        }
+      }
+    }
+    return {}
+  }
+})
+
+const addFormData = $ref([]);
+
+handleAdd();
+function handleAdd() {
+  let obj = {
+    xhs_zcmc: "",
+    xhs_ggxh: "",
+    xhs_zcfl: "",
+    xhs_zcfl_bh: "",
+    xhs_zcpc: "",
+    xhs_zcdj: "",
+    xhs_sl: "",
+    xhs_dw: "",
+    xhs_ssbm: "",
+    xhs_zj: 0,
+    xhs_gmsj: "",
+  }
+  if (addFormData[0]) {
+    obj.xhs_zcfl = addFormData[0].xhs_zcfl;
+    obj.xhs_zcfl_bh = addFormData[0].xhs_zcfl_bh;
+  }
+  addFormData.unshift(obj);
+}
+
+function handleRemove(index) {
+  addFormData.splice(index, 1);
+}
+
+function handleZjChange(obj) {
+  if (obj.xhs_zcdj && obj.xhs_sl) {
+    obj.xhs_zj = (parseFloat(obj.xhs_zcdj) * parseFloat(obj.xhs_sl)).toFixed(2);
+  }
+}
+
+let showDatePicker = $ref(false);
+const minDate = new Date(2010, 0, 1);
+const currentDate = $ref([new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()]);
+function onDateConfirm({ selectedValues }, data) {
+  data.xhs_gmsj = selectedValues.join('-');
+  showDatePicker = false;
+}
+
+
+let options = $ref([]);
+const fieldNames = {
+  text: 'label',
+  value: 'value',
+  children: 'children',
+};
+let show = $ref(false);
+const cascaderValue = $ref('');
+async function initClassData() {
+  let { code, data } = await request({ url: '/xdhq/hqgl_xcgllb/tree' });
+  options = data.tree_data;
+}
+initClassData();
+
+function onFinish({ selectedOptions, value }, data) {
+  data.xhs_zcfl = selectedOptions.map((option) => option.label).join('/');
+  data.xhs_zcfl_bh = value;
+  show = false;
+}
+
+const onSubmit = async () => {
+  let arr = [];
+  addFormData.map((item) => {
+    arr.push(Object.assign(item, dialogForm_Data_add_extend.value, { xhs_spzt: '1' }));
+  })
+  let obj = {
+    xdhq_hqgl_sbsg: arr,
+  }
+  let { code } = await request({ url: '/xdhq/hqgl_sbsg/add', data: obj });
+  if (code == 1) {
+    router.back();
+    showSuccessToast('保存成功');
+  }
+};
+</script>
+
+<style>
+</style>