Browse Source

任务/悬赏/模板新增积分规则选项

walter 9 months ago
parent
commit
5726c65dc4

+ 1 - 1
build/webpack.prod.conf.js

@@ -35,7 +35,7 @@ const webpackConfig = merge(baseWebpackConfig, {
     new BundleAnalyzerPlugin({
       analyzerMode: 'server',
       analyzerHost: '127.0.0.1',
-      analyzerPort: 8889,
+      analyzerPort: 8890,
       reportFilename: 'report.html',
       defaultSizes: 'parsed',
       openAnalyzer: true,

+ 1 - 1
src/components/AppealRewrite.vue

@@ -3,7 +3,7 @@
     v-model="showAppealRewrite"
     position="bottom"
     duration="0.2"
-    :style="{height: '100%', width:'100%','background-color': 'rgb(245, 245, 245)'}"
+    :style="{height: '90%', width:'100vw','background-color': 'rgb(245, 245, 245)'}"
     @open="onOpen"
     @closed="onClosed"
   >

+ 5 - 0
src/components/CategorySelectorCell.vue

@@ -45,6 +45,7 @@
       :visible.sync="show_dept_selector"
       :selected.sync="selected_data"
       :cycle_type="cycle_type"
+      :scope="scope"
     ></RuleCategorySelector>
   </van-cell>
 </template>
@@ -111,6 +112,10 @@ export default {
       type: Number,
       default: 0
     },
+    scope:{
+      type: Boolean,
+      default: false
+    }
   },
   watch: {
     selected(val) {

+ 64 - 2
src/components/RuleCategorySelector.vue

@@ -7,7 +7,7 @@
       <a v-for="(item, index) in pid_list_arr" :key="index" href="javascript:void(0);" @click="back_by_index(index + 1)"> <van-icon name="arrow" /> {{item.name}}</a>
     </div>
     <div class="body_com" :class="{show_dept_path:pid_list_arr.length > 0}">
-      <scroller :on-refresh="get_category_list">
+      <scroller :on-refresh="tt">
         <van-cell-group>
         <van-cell :is-link="!can_select_category" v-for="(item,index) in category_list" :key="index" :title="item.name" v-show="item.pid == pid && item.name.indexOf(keyword) >= 0 && category_not_select.indexOf(item.id) < 0" class="employee_cell" @click="select_dept(item)">
           <template slot="icon">
@@ -115,6 +115,10 @@ export default {
       type: Number,
       default: 0
     },
+    scope:{
+      type: Boolean,
+      default: false
+    }
   },
   name: 'RuleCategorySelector',
   data () {
@@ -379,7 +383,65 @@ export default {
         this.parse_tree(trees[i].child, rule_id)
       }
     },
+    getRuleScope(done){
+      let data = {
+        cycle_type:this.cycle_type,
+        pt_id:this.ptId
+      }
+      this.$axiosUser('get','/api/pro/integral/rule/trees/scope',data)
+        .then((res)=>{
+          this.category_list = []
+          this.item_list = res.data.data.item_list
+          this.rule_tree = res.data.data.rule_tree
+          this.parse_tree(res.data.data.rule_tree, this.pid)
+          for (let i in this.category_list) {
+            this.category_list[i]['checked'] = false
+            if (this.category_selected.indexOf(this.category_list[i].id) >= 0) {
+              this.category_list[i]['checked'] = true
+              if (this.cate_multi == false) {
+                this.parse_tree(this.rule_tree, this.category_list[i].id)
+              }
+              this.$emit('get_items', this.cur_item_list)
+              this.category_list = []
+              this.parse_tree(res.data.data.rule_tree, this.pid)
+            }
+          }
+
+          if (this.pid == 0) {
+            this.list = []
+            for (let i in this.item_list) {
+              for (let k in this.item_list[i]) {
+                this.list.push(this.item_list[i][k])
+              }
+            }
+          } else {
+            this.list = this.cur_item_list
+          }
+          for (let i in this.list) {
+            this.list[i]['checked'] = false
+            if (this.rule_selected.indexOf(this.list[i].id) >= 0) {
+              this.list[i]['checked'] = true
+            }
+          }
+
+          done()
+          this.$toast.clear()
+        })
+        .catch(e => {
+          done()
+          this.$toast.clear()
+        })
+    },
+    tt(done){
+      this.get_category_list(done)
+    },
     get_category_list (done) {
+      //根据可见范围查询分类树
+      if (this.scope){
+        this.getRuleScope(done)
+        return
+      }
+
       this.category_list = []
       let params = {
         cycle_type:this.cycle_type
@@ -465,7 +527,7 @@ export default {
     this.deptIds = this.$userInfo().employee_detail.dept_list.map(item => {
       return item.dept_id
     })
-    this.get_category_list(function () {})
+    // this.get_category_list(function () {})
     this.get_point_types()
     this.$nextTick(() => {
       if (this.append_body) {

+ 21 - 2
src/components/RuleCategorySelector1.vue

@@ -104,6 +104,10 @@ export default {
       type: Number,
       default: 1
     },
+    scope:{
+      type: Boolean,
+      default: false
+    }
   },
   name: 'RuleCategorySelector',
   data () {
@@ -340,7 +344,18 @@ export default {
         this.parse_tree(trees[i].child, rule_id)
       }
     },
-
+    getRuleScope(){
+      let data = {
+        cycle_type:this.cycle_type,
+        pt_id:this.ptId
+      }
+      this.$axiosUser('get','/api/pro/integral/rule/trees/scope',data)
+        .then((res)=>{
+          this.category_list = []
+          this.rule_tree = res.data.data.rule_tree
+          this.parse_tree(res.data.data.rule_tree, this.pid)
+        })
+    },
     get_category_list () {
       let params = {}
       if(this.ptId){ //指定分类
@@ -364,7 +379,11 @@ export default {
     if (document.documentElement.style.height) {
       this.com_height = document.documentElement.style.height
     }
-    this.get_category_list();
+    if (this.scope){
+      this.getRuleScope()
+    }else {
+      this.get_category_list();
+    }
   }
 }
 </script>

+ 17 - 9
src/components/RuleCategorySelectorCell1.vue

@@ -3,7 +3,6 @@
     class="employee_cell"
     :title="title"
     :value="value"
-    :label="label"
     :icon="icon"
     :url="url"
     :border="border"
@@ -19,19 +18,24 @@
         选择了{{selected_data.rule.length}}条规则
       </div>
     </template>
+    <template slot="label">
+      <slot name="label">{{label}}</slot>
+    </template>
 
     <RuleCategorySelector1
-    :ptId="ptId"
-    :multi.sync="multi"
-    :max="max"
-    :close_clear_data="false"
-     ref="selector"
-     @confirm="confirm"
-    :can_select_category="false"
+      :scope="scope"
+      :ptId="ptId"
+      :multi.sync="multi"
+      :max="max"
+      :close_clear_data="false"
+      ref="selector"
+      @confirm="confirm"
+      :can_select_category="false"
      :visible.sync="show_dept_selector"
      :selected.sync="selected_data"
      :append_body="true"
-     :cycle_type="cycle_type">
+     :cycle_type="cycle_type"
+    >
      <template slot="append">
       <slot name="append"></slot>
     </template></RuleCategorySelector1>
@@ -108,6 +112,10 @@ export default {
     activeIndex: {
       type: Number
     },
+    scope:{
+      type: Boolean,
+      default:false,
+    }
   },
   watch: {
     selected (val) {

+ 529 - 0
src/point/view/task/TaskEdit.vue

@@ -0,0 +1,529 @@
+<template>
+  <div>
+    <van-nav-bar
+      title="悬赏更新"
+      left-text="返回"
+      @click-left="$route_back"
+      left-arrow
+    />
+    <div class="content">
+      <scroller :is-need="isNeed">
+        <van-cell-group>
+          <van-cell required>
+            <Mtextarea
+              v-model="formData.task_name"
+              name="任务内容"
+              v-validate="'required|max:20'"
+              placeholder="请输入任务内容"
+              :text_max="20"
+              :imgs_max="3"
+              images
+              :imgs.sync="formData.file_list"
+            ></Mtextarea>
+          </van-cell>
+        </van-cell-group>
+
+        <van-cell-group class="point-field">
+          <van-cell title="积分类型" required id="task_types">
+            <template slot="right-icon">
+              <van-radio-group v-model="formData.pt_id" direction="horizontal" class="radio_button">
+                <van-radio checked-color class="list" :name="item.id" v-for="(item, index) in pts" v-if="item.code !== 'JX'" :key="index">{{ item.name }}</van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+          <van-cell title="指定规则">
+            <template slot="right-icon">
+              <van-radio-group
+                v-model="formData.rule_type"
+                direction="horizontal"
+              >
+                <van-radio class="list" :name="0" >
+                  <span class="rule_type_span">不指定</span>
+                </van-radio>
+                <van-radio class="list" :name="1" >
+                  <span class="rule_type_span">分类</span>
+                </van-radio>
+                <van-radio class="list" :name="2" >
+                  <span class="rule_type_span">规则</span>
+                </van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+
+          <!--     选择分类     -->
+          <CategorySelectorCell
+            v-if="formData.rule_type === 1"
+            title="细则分类"
+            v-model="rules"
+            required
+            :pt-id="formData.pt_id"
+            :multi="false"
+            scope
+          />
+
+          <!--选择规则  -->
+          <RuleCategorySelectorCell
+            v-if="formData.rule_type === 2"
+            :pt-id="formData.pt_id"
+            required
+            name="请选择积分规则"
+            title="积分规则"
+            v-model="rule_items"
+            scope
+            :multi="false"
+          >
+            <template slot="label">
+              <span style="color: red">{{ruleItemLabel}}</span>
+            </template>
+          </RuleCategorySelectorCell>
+
+          <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required/>
+          <NumberInput v-model="formData.base_point" v-validate="'required'"  :min="minPoint" :max="maxPoint"/>
+        </van-cell-group>
+
+        <van-cell-group>
+          <EmployeeSelectorCell
+            required
+            title="审批人"
+            iconType="records"
+            :show_manager_only="true"
+            v-model="reviewer"
+            v-validate="'required'"
+            name="审批人"
+            :multi="false"
+          />
+          <DateTimeCell
+            required
+            title="截止时间"
+            v-validate="'required'"
+            name="截止时间"
+            v-model="formData.expire_time"
+          />
+          <van-field v-model="formData.ahead_award_point" type="digit">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>提前奖分(天)</span>
+                <span class="flex-1 red" style="text-align: right;">+</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.ahead_award_point_limit" type="digit" label="奖分上限">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>奖分上限</span>
+                <span class="flex-1 red" style="text-align: right;">+</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.timeout_deduction_point" type="digit" label="逾期扣分(天)">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>逾期扣分(天)</span>
+                <span class="flex-1 green" style="text-align: right;">-</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.timeout_deduction_point_limit" type="digit" label="扣分上限">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>扣分上限</span>
+                <span class="flex-1 green" style="text-align: right;">-</span>
+              </div>
+            </template>
+          </van-field>
+        </van-cell-group>
+
+        <van-cell-group :border="false">
+          <van-cell title="任务备注"/>
+          <van-cell>
+            <Mtextarea v-model="formData.task_remark" placeholder="请输入关于任务备注" :text_max="300"/>
+          </van-cell>
+          <DeptSelectorCell title="可见范围" v-model="departments"></DeptSelectorCell>
+        </van-cell-group>
+
+
+        <van-button type="info" block @click="taskSubmit">确定修改</van-button>
+        <div style="height: 1rem;"></div>
+      </scroller>
+    </div>
+  </div>
+</template>
+
+<script>
+import Mtextarea from "@/components/Mtextarea";
+import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
+import CategorySelectorCell from '@/components/CategorySelectorCell'
+import NumberInput from '@/components/NumberInput';
+import EmployeeSelectorCell from '@/components/EmployeeSelectorCell';
+import DateTimeCell from '@/components/DateTimeCell'
+import DeptSelectorCell from '@/components/DeptSelectorCell'
+
+export default {
+  name: "TaskEdit",
+  components:{
+    Mtextarea,
+    RuleCategorySelectorCell,
+    CategorySelectorCell,
+    NumberInput,
+    EmployeeSelectorCell,
+    DateTimeCell,
+    DeptSelectorCell
+  },
+  props:{
+    taskId:{
+      require:true,
+      type: String
+    }
+  },
+  data(){
+    return {
+      isNeed: !this.$getCache('isAndroid'),
+      pts:this.$getTypes,
+      rule_items:[],
+      rules:[],
+      reviewer:[],
+      departments:[],
+      hasInit:false,
+      formData:{
+        id:0,
+        pt_id:0,
+        base_point:0,
+        expire_time:'',
+        reviewer_id:0,
+        rule_type:0,
+        rule_id:0,
+        item_id:0,
+        rule_item:{
+          id:0,
+          remark:"",
+          cycle_type: 0,
+          is_attendance: 0,
+          max_point: 0,
+          min_point: 0,
+          prize_type: 0,
+          pt_id: 0,
+          range_type: 0,
+          rule_id: 0,
+        },
+        task_remark:'',
+        task_name:'',
+        file_list: [],
+        ahead_award_point:0,
+        ahead_award_point_limit:0,
+        timeout_deduction_point:0,
+        timeout_deduction_point_limit:0,
+        dept_ids:[],
+        dept_names:''
+      }
+    }
+  },
+  watch:{
+    'formData.pt_id'(v){
+      if (this.hasInit && this.formData.rule_type === 2) this.initRuleData()
+    },
+    'formData.rule_type'(v){
+      if(this.hasInit) this.initRuleData()
+    },
+    rules(rules){
+      if (this.hasInit) this.formData.rule_id = rules.length <= 0 ? 0 : rules[0].id
+    },
+    rule_items(items){
+      if (!this.hasInit) return
+      this.formData.rule_item = items.length <= 0 ? {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      } : {
+        id:items[0].id,
+        remark:items[0].remark,
+        cycle_type: items[0].cycle_type,
+        is_attendance: items[0].is_attendance,
+        max_point: items[0].max_point,
+        min_point: items[0].min_point,
+        prize_type: items[0].prize_type,
+        pt_id: items[0].pt_id,
+        range_type: items[0].range_type,
+        rule_id: items[0].rule_id,
+      }
+      this.formData.rule_id = this.formData.rule_item.rule_id
+      this.formData.item_id = this.formData.rule_item.id
+      this.formData.base_point = this.formData.rule_item.min_point !== 0 ? this.formData.rule_item.min_point : 1
+    },
+    reviewer(v){
+      if (v.length === 0){
+        this.formData.reviewer_id = 0
+      } else {
+        this.formData.reviewer_id = v[0].id
+      }
+    },
+    departments(v){
+      if (v.length === 0){
+        this.formData.dept_ids = []
+      }else {
+        this.formData.dept_ids = v.map(item => item.dept_id)
+      }
+    },
+  },
+  computed:{
+    ruleItemLabel(){
+      if (this.formData.rule_item.id <= 0) return ''
+      let pt = this.pts.find( t => t.id === this.formData.rule_item.pt_id)
+      return this.formData.rule_item.range_type === 1 ? `${this.formData.rule_item.min_point} ${pt.name}` : `${this.formData.rule_item.min_point} - ${this.formData.rule_item.max_point} ${pt.name}`
+    },
+    minPoint(){
+      return this.formData.rule_type !== 2 ? 1 : (this.formData.rule_item.id <= 0 ? 1 : this.formData.rule_item.min_point)
+    },
+    maxPoint(){
+      return this.formData.rule_type !== 2 ? 100000 : (this.formData.rule_item.id <= 0 ? 1 : this.formData.rule_item.max_point)
+    }
+  },
+  methods:{
+    initRuleData(){
+      this.formData.rule_id = 0
+      this.formData.item_id = 0
+      this.formData.rule_item = {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      }
+      this.formData.base_point = 1
+      this.rules = []
+      this.rule_items = []
+    },
+    getInfo(){
+      if (!this.taskId){
+        this.$toast.fail('悬赏信息丢失')
+        return
+      }
+
+      this.$toast.loading({
+        loadingType: 'spinner',
+        forbidClick:true
+      })
+
+      let data = {
+        task_id:this.taskId
+      }
+      this.hasInit = false
+      this.$axiosUser('get','/api/pro/integral/task',data)
+        .then(res => {
+          if (res.data.code !== 1) throw new Error(res.data.msg)
+
+          let info = res.data.data
+          let formData = {
+            id:info.id,
+            pt_id:info.pt_id,
+            base_point:info.point_config.base_point,
+            expire_time:info.expire_time,
+            reviewer_id:info.reviewer_id,
+            rule_type:0,
+            rule_id:info.rule_id,
+            item_id:info.item_id,
+            rule_item:{
+              id:0,
+              remark:"",
+              cycle_type: 0,
+              is_attendance: 0,
+              max_point: 0,
+              min_point: 0,
+              prize_type: 0,
+              pt_id: 0,
+              range_type: 0,
+              rule_id: 0,
+            },
+            task_remark:info.task_remark,
+            task_name:info.task_name,
+            task_file_list: info.task_file_list,
+            ahead_award_point:info.point_config.ahead_award_point,
+            ahead_award_point_limit:info.point_config.ahead_award_point_limit,
+            timeout_deduction_point:info.point_config.timeout_deduction_point,
+            timeout_deduction_point_limit:info.point_config.timeout_deduction_point_limit,
+            dept_ids:[],
+            dept_names:'',
+          }
+          if (info.item_info){
+            formData.rule_item = {
+              id:info.item_id,
+              remark:info.item_info.remark,
+              cycle_type: info.item_info.cycle_type,
+              is_attendance: info.item_info.is_attendance,
+              max_point: info.item_info.max_point,
+              min_point: info.item_info.min_point,
+              prize_type: info.item_info.prize_type,
+              pt_id: info.item_info.pt_id,
+              range_type: info.item_info.range_type,
+              rule_id: info.rule_id,
+            }
+            this.rule_items = [formData.rule_item]
+          } else if (info.rule_info){
+            this.rules = [{id:info.rule_info.id,name:info.rule_info.name}]
+          }
+          this.reviewer = [{id:info.reviewer_id,name:info.reviewer_name,img_url:info.reviewer_img_url}]
+          formData.rule_type = formData.item_id > 0 && formData.rule_id > 0 ? 2 : (formData.rule_id > 0 ? 1 : 0)
+          this.departments = []
+          if (info.department_info){
+            info.department_info.forEach((item,index) => {
+              formData.dept_ids.push(item.id)
+              this.departments.push({dept_id: item.id, dept_name: item.name})
+              formData.dept_names +=  index === 0 ? item.name : `,${item.name}`
+            })
+          }
+
+          this.formData = formData
+
+
+          this.$nextTick(() => {
+            this.hasInit = true
+          })
+        })
+        .catch(err => {
+          this.$toast.fail(err)
+        })
+        .finally(() => {
+          this.$toast.clear()
+        })
+
+    },
+    taskSubmit(){
+      if (this.formData.rule_type === 1 && this.formData.rule_id <= 0){
+        this.$toast.fail('请选择规则分类')
+        return
+      }
+      if (this.formData.rule_type === 2 && this.formData.item_id <= 0){
+        this.$toast.fail('请选择积分规则')
+        return
+      }
+      this.$validator.validate().then(result => {
+        if (!result){
+          this.$notify({type: 'danger', message: this.$validator.errors.items[0].msg});
+        }else {
+          this.sub()
+        }
+      })
+    },
+    ahead_timeout(item,arr,codes,code){
+      if(item){
+        if(arr){
+          if(Number(item) > Number(arr)){
+            this.$notify({type: 'danger', message: code + '上限不能小于每日' + codes});
+            return true
+          }
+        }else{
+          this.$notify({type: 'danger', message:codes + '不为0时,' + code + '上限不能为空'});
+          return true
+        }
+      }
+    },
+    sub(){
+      let data = {
+        id:this.formData.id,
+        pt_id:this.formData.pt_id,
+        task_name:this.formData.task_name,
+        task_remark:this.formData.task_remark,
+        base_point:this.formData.base_point,
+        expire_time:this.formData.expire_time,
+        reviewer_id:this.formData.reviewer_id,
+        timeout_deduction_point:this.formData.timeout_deduction_point,
+        timeout_deduction_point_limit:this.formData.timeout_deduction_point_limit,
+        ahead_award_point:this.formData.ahead_award_point,
+        ahead_award_point_limit:this.formData.ahead_award_point_limit,
+        dept_ids:this.formData.dept_ids,
+        rule_id:this.formData.rule_id,
+        item_id:this.formData.item_id,
+      }
+      if (!data.ahead_award_point && data.ahead_award_point_limit) {
+        this.$notify({type: 'danger', message: '奖分上限不为0时,提前奖分不能为空'});
+        return;
+      } else if (data.ahead_award_point && !data.ahead_award_point_limit) {
+        this.$notify({type: 'danger', message: '提前奖分不为0时,奖分上限不能为空'});
+        return;
+      }
+      if (!data.timeout_deduction_point && data.timeout_deduction_point_limit) {
+        this.$notify({type: 'danger', message: '扣分上限不为0时,逾期扣分不能为空'});
+        return;
+      } else if (data.timeout_deduction_point && !data.timeout_deduction_point_limit) {
+        this.$notify({type: 'danger', message: '逾期扣分不为0时,扣分上限不能为空'});
+        return;
+      }
+
+      if (this.ahead_timeout(data.ahead_award_point, data.ahead_award_point_limit, '提前奖分', '奖分')) return;
+      if (this.ahead_timeout(data.timeout_deduction_point, data.timeout_deduction_point_limit, '逾期扣分', '扣分')) return;
+
+      let point_limit = this.$userInfo().point_config.point_limit ? this.$userInfo().point_config.point_limit.find(pt => pt.pt_id === 3) : null
+      if (!this.$userInfo().is_creator && point_limit) {
+        let entry_limit = Number(point_limit.point);
+        if (entry_limit > 0) {
+          if (data.ahead_award_point > entry_limit || data.timeout_deduction_point > entry_limit) {
+            this.$notify({type: 'danger', message: '每日奖扣分 不能超过您的奖扣分权限(您的奖扣分权限:' + entry_limit + '分)'});
+            return;
+          }
+          if (data.ahead_award_point_limit > entry_limit * 10 || data.timeout_deduction_point_limit > entry_limit * 10) {
+            this.$notify({type: 'danger', message: '奖扣分上限不能超过' + entry_limit * 10 + '分(您的奖扣分权限' + entry_limit + '分*10)'});
+            return;
+          }
+        }
+      }
+
+      let self = this
+      self.$toast.loading({
+        loadingType: 'spinner',
+        forbidClick:true
+      })
+
+      self.$axiosUser('post','/api/pro/integral/task/update',data)
+        .then(res => {
+          if (res.data.code !== 1) throw new Error(res.data.msg)
+
+          self.$toast.success(res.data.msg)
+          setTimeout(() => {
+            self.$route_back()
+          },500)
+        })
+        .catch(err => {
+          self.$toast.fail(err)
+        })
+        .finally(() => {
+          self.$toast.clear()
+        })
+
+
+    }
+  },
+  activated() {
+    this.getInfo()
+  }
+}
+</script>
+
+
+<style scoped lang="less">
+.content{
+  height: calc(100% - 0.92rem);
+  position: relative;
+  overflow-y: scroll;
+}
+.point-field /deep/ .van-cell__title.van-field__label span {
+  width: 0;
+  color: transparent;
+  height: 0;
+  overflow: hidden;
+  font-size: 0;
+}
+.point-field /deep/ .van-cell__title {
+  width: 0;
+}
+</style>

+ 520 - 0
src/point/view/task/WorkEdit.vue

@@ -0,0 +1,520 @@
+<template>
+  <div>
+    <van-nav-bar
+      title="任务更新"
+      left-text="返回"
+      @click-left="$route_back"
+      left-arrow
+    />
+    <div class="content">
+      <scroller :is-need="isNeed">
+        <van-cell-group>
+          <van-cell required>
+            <Mtextarea
+              v-model="formData.task_name"
+              name="任务内容"
+              v-validate="'required|max:20'"
+              placeholder="请输入任务内容"
+              :text_max="20"
+              :imgs_max="3"
+              images
+              :imgs.sync="formData.file_list"
+            ></Mtextarea>
+          </van-cell>
+        </van-cell-group>
+
+        <van-cell-group class="point-field">
+          <van-cell title="积分类型" required id="task_types">
+            <template slot="right-icon">
+              <van-radio-group v-model="formData.pt_id" direction="horizontal" class="radio_button">
+                <van-radio checked-color class="list" :name="item.id" v-for="(item, index) in pts" v-if="item.code !== 'JX'" :key="index">{{ item.name }}</van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+          <van-cell title="指定规则">
+            <template slot="right-icon">
+              <van-radio-group
+                v-model="formData.rule_type"
+                direction="horizontal"
+              >
+                <van-radio class="list" :name="0" >
+                  <span class="rule_type_span">不指定</span>
+                </van-radio>
+                <van-radio class="list" :name="1" >
+                  <span class="rule_type_span">分类</span>
+                </van-radio>
+                <van-radio class="list" :name="2" >
+                  <span class="rule_type_span">规则</span>
+                </van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+
+          <!--     选择分类     -->
+          <CategorySelectorCell
+            v-if="formData.rule_type === 1"
+            title="细则分类"
+            v-model="rules"
+            required
+            :pt-id="formData.pt_id"
+            :multi="false"
+            scope
+          />
+
+          <!--选择规则  -->
+          <RuleCategorySelectorCell
+            v-if="formData.rule_type === 2"
+            :pt-id="formData.pt_id"
+            required
+            name="请选择积分规则"
+            title="积分规则"
+            v-model="rule_items"
+            scope
+            :multi="false"
+          >
+            <template slot="label">
+              <span style="color: red">{{ruleItemLabel}}</span>
+            </template>
+          </RuleCategorySelectorCell>
+
+          <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required/>
+          <NumberInput v-model="formData.base_point" v-validate="'required'"  :min="minPoint" :max="maxPoint"/>
+        </van-cell-group>
+
+        <van-cell-group>
+          <EmployeeSelectorCell
+            required
+            title="执行人"
+            :max="10"
+            is_employee_list
+            v-validate="'required'"
+            :employee_list="$userInfo().employee_detail.manage_scope"
+            name="执行人"
+            :multi="false"
+            v-model="executor_name"
+          />
+          <EmployeeSelectorCell
+            required
+            title="审批人"
+            iconType="records"
+            :show_manager_only="true"
+            v-model="reviewer"
+            v-validate="'required'"
+            name="审批人"
+            :multi="false"
+          />
+          <DateTimeCell
+            required
+            title="截止时间"
+            v-validate="'required'"
+            name="截止时间"
+            v-model="formData.expire_time"
+          />
+          <van-field v-model="formData.ahead_award_point" type="digit">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>提前奖分(天)</span>
+                <span class="flex-1 red" style="text-align: right;">+</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.ahead_award_point_limit" type="digit" label="奖分上限">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>奖分上限</span>
+                <span class="flex-1 red" style="text-align: right;">+</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.timeout_deduction_point" type="digit" label="逾期扣分(天)">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>逾期扣分(天)</span>
+                <span class="flex-1 green" style="text-align: right;">-</span>
+              </div>
+            </template>
+          </van-field>
+          <van-field v-model="formData.timeout_deduction_point_limit" type="digit" label="扣分上限">
+            <template slot="label">
+              <div class="flex-box-ce">
+                <span>扣分上限</span>
+                <span class="flex-1 green" style="text-align: right;">-</span>
+              </div>
+            </template>
+          </van-field>
+        </van-cell-group>
+        <van-cell-group :border="false">
+          <van-cell title="任务备注"/>
+          <van-cell>
+            <Mtextarea v-model="formData.task_remark" placeholder="请输入关于任务备注" :text_max="300"/>
+          </van-cell>
+        </van-cell-group>
+
+        <van-button type="info" block @click="taskSubmit">确定修改</van-button>
+        <div style="height: 1rem;"></div>
+      </scroller>
+    </div>
+  </div>
+</template>
+
+<script>
+import Mtextarea from "@/components/Mtextarea";
+import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
+import CategorySelectorCell from '@/components/CategorySelectorCell'
+import NumberInput from '@/components/NumberInput';
+import EmployeeSelectorCell from '@/components/EmployeeSelectorCell';
+import DateTimeCell from '@/components/DateTimeCell'
+
+export default {
+  name: "WorkEdit",
+  components: {
+    Mtextarea,
+    RuleCategorySelectorCell,
+    CategorySelectorCell,
+    NumberInput,
+    EmployeeSelectorCell,
+    DateTimeCell,
+  },
+  props:{
+    workId:{
+      require:true,
+      type: String
+    }
+  },
+  data() {
+    return {
+      isNeed: !this.$getCache('isAndroid'),
+      pts:this.$getTypes,
+      rule_items:[],
+      rules:[],
+      executor_name:[],
+      reviewer:[],
+      hasInit:false,
+      formData:{
+        id:0,
+        pt_id:0,
+        publisher_id:0,
+        base_point:0,
+        expire_time:'',
+        reviewer_id:0,
+        rule_type:0,
+        rule_id:0,
+        item_id:0,
+        rule_item:{
+          id:0,
+          remark:"",
+          cycle_type: 0,
+          is_attendance: 0,
+          max_point: 0,
+          min_point: 0,
+          prize_type: 0,
+          pt_id: 0,
+          range_type: 0,
+          rule_id: 0,
+        },
+        task_remark:'',
+        task_name:'',
+        targets:[],
+        file_list: [],
+        ahead_award_point:0,
+        ahead_award_point_limit:0,
+        timeout_deduction_point:0,
+        timeout_deduction_point_limit:0,
+      }
+    }
+  },
+  watch:{
+    'formData.pt_id'(v){
+      if (this.hasInit && this.formData.rule_type === 2) this.initRuleData()
+    },
+    executor_name(v){
+      if (v.length === 0){
+        this.formData.targets = []
+      } else {
+        this.formData.targets = [v[0].id]
+      }
+    },
+    'formData.rule_type'(v){
+      if (this.hasInit) this.initRuleData()
+    },
+    rules(rules){
+      if (this.hasInit) this.formData.rule_id = rules.length <= 0 ? 0 : rules[0].id
+    },
+    rule_items(items){
+      if (!this.hasInit) return
+      this.formData.rule_item = items.length <= 0 ? {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      } : {
+        id:items[0].id,
+        remark:items[0].remark,
+        cycle_type: items[0].cycle_type,
+        is_attendance: items[0].is_attendance,
+        max_point: items[0].max_point,
+        min_point: items[0].min_point,
+        prize_type: items[0].prize_type,
+        pt_id: items[0].pt_id,
+        range_type: items[0].range_type,
+        rule_id: items[0].rule_id,
+      }
+      this.formData.rule_id = this.formData.rule_item.rule_id
+      this.formData.item_id = this.formData.rule_item.id
+      this.formData.base_point = this.formData.rule_item.min_point !== 0 ? this.formData.rule_item.min_point : 1
+    },
+    reviewer(v){
+      if (v.length === 0){
+        this.formData.reviewer_id = 0
+      } else {
+        this.formData.reviewer_id = v[0].id
+      }
+    }
+  },
+  computed:{
+    ruleItemLabel(){
+      if (this.formData.rule_item.id <= 0) return ''
+      let pt = this.pts.find( t => t.id === this.formData.rule_item.pt_id)
+      return this.formData.rule_item.range_type === 1 ? `${this.formData.rule_item.min_point} ${pt.name}` : `${this.formData.rule_item.min_point} - ${this.formData.rule_item.max_point} ${pt.name}`
+    },
+    minPoint(){
+      return this.formData.rule_type !== 2 ? 1 : (this.formData.rule_item.id <= 0 ? 1 : this.formData.rule_item.min_point)
+    },
+    maxPoint(){
+      return this.formData.rule_type !== 2 ? 100000 : (this.formData.rule_item.id <= 0 ? 1 : this.formData.rule_item.max_point)
+    }
+  },
+  methods:{
+    initRuleData(){
+      this.formData.rule_id = 0
+      this.formData.item_id = 0
+      this.formData.rule_item = {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      }
+      this.formData.base_point = 1
+      this.rules = []
+      this.rule_items = []
+    },
+    getInfo(){
+      if (!this.workId){
+        this.$toast.fail('任务信息丢失')
+        return
+      }
+
+      this.$toast.loading({
+        loadingType: 'spinner',
+        forbidClick:true
+      })
+
+      this.hasInit = false
+      this.$axiosUser('get', '/api/pro/integral/work', { work_id: this.workId })
+        .then(res => {
+          if (res.data.code !== 1){
+            this.$toast.fail(res.data.msg)
+            return
+          }
+          let info = res.data.data
+          this.formData = {
+            id:info.id,
+            pt_id:info.pt_id,
+            publisher_id:info.publisher_id,
+            base_point:info.point_config.base_point,
+            expire_time:info.expire_time,
+            reviewer_id:info.reviewer_id,
+            rule_type:0,
+            rule_id:info.rule_id,
+            item_id:info.item_id,
+            rule_item:{
+              id:0,
+              remark:"",
+              cycle_type: 0,
+              is_attendance: 0,
+              max_point: 0,
+              min_point: 0,
+              prize_type: 0,
+              pt_id: 0,
+              range_type: 0,
+              rule_id: 0,
+            },
+            task_remark:info.task_remark,
+            task_name:info.task_name,
+            targets:[info.employee_id],
+            file_list: info.task_file_list ? info.task_file_list : [],
+            ahead_award_point:info.point_config.ahead_award_point,
+            ahead_award_point_limit:info.point_config.ahead_award_point_limit,
+            timeout_deduction_point:info.point_config.timeout_deduction_point,
+            timeout_deduction_point_limit:info.point_config.timeout_deduction_point_limit,
+          }
+          if (info.item_info){
+            this.formData.rule_item = {
+              id:info.item_id,
+              remark:info.item_info.remark,
+              cycle_type: info.item_info.cycle_type,
+              is_attendance: info.item_info.is_attendance,
+              max_point: info.item_info.max_point,
+              min_point: info.item_info.min_point,
+              prize_type: info.item_info.prize_type,
+              pt_id: info.item_info.pt_id,
+              range_type: info.item_info.range_type,
+              rule_id: info.rule_id,
+            }
+            this.rule_items = [this.formData.rule_item]
+          } else if (info.rule_info){
+            this.rules = [{id:info.rule_info.id,name:info.rule_info.name}]
+          }
+          this.executor_name = [{id:info.employee_id,name:info.employee_name,img_url:info.img_url}]
+          this.reviewer = [{id:info.reviewer_id,name:info.reviewer_name,img_url:info.reviewer_img_url}]
+          this.formData.rule_type = this.formData.item_id > 0 && this.formData.rule_id > 0 ? 2 : (this.formData.rule_id > 0 ? 1 : 0)
+
+
+          this.$nextTick(() => {
+            this.hasInit = true
+          })
+        })
+        .finally(() => {
+          this.$toast.clear()
+        })
+    },
+    taskSubmit(){
+      if (this.formData.rule_type === 1 && this.formData.rule_id <= 0){
+        this.$toast.fail('请选择规则分类')
+        return
+      }
+      if (this.formData.rule_type === 2 && this.formData.item_id <= 0){
+        this.$toast.fail('请选择积分规则')
+        return
+      }
+      this.$validator.validate().then(result => {
+        if (!result){
+          this.$notify({type: 'danger', message: this.$validator.errors.items[0].msg});
+        }else {
+          this.sub()
+        }
+      })
+    },
+    ahead_timeout(item,arr,codes,code){
+      if(item){
+        if(arr){
+          if(Number(item) > Number(arr)){
+            this.$notify({type: 'danger', message: code + '上限不能小于每日' + codes});
+            return true
+          }
+        }else{
+          this.$notify({type: 'danger', message:codes + '不为0时,' + code + '上限不能为空'});
+          return true
+        }
+      }
+    },
+    sub(){
+      let data = {
+        id:this.formData.id,
+        targets:this.formData.targets,
+        pt_id:this.formData.pt_id,
+        task_name:this.formData.task_name,
+        task_remark:this.formData.task_remark,
+        base_point:Number(this.formData.base_point),
+        expire_time:this.formData.expire_time,
+        package_id:0,
+        weight:0,
+        file_list:this.formData.file_list,
+        reviewer_id:this.formData.reviewer_id,
+        ahead_award_point:this.formData.ahead_award_point,
+        ahead_award_point_limit:this.formData.ahead_award_point_limit,
+        timeout_deduction_point:this.formData.timeout_deduction_point,
+        timeout_deduction_point_limit:this.formData.timeout_deduction_point_limit,
+        rule_id:this.formData.rule_id,
+        item_id:this.formData.item_id,
+      }
+      if (!data.ahead_award_point && data.ahead_award_point_limit) {
+        this.$notify({type: 'danger', message: '奖分上限不为0时,提前奖分不能为空'});
+        return;
+      } else if (data.ahead_award_point && !data.ahead_award_point_limit) {
+        this.$notify({type: 'danger', message: '提前奖分不为0时,奖分上限不能为空'});
+        return;
+      }
+      if (!data.timeout_deduction_point && data.timeout_deduction_point_limit) {
+        this.$notify({type: 'danger', message: '扣分上限不为0时,逾期扣分不能为空'});
+        return;
+      } else if (data.timeout_deduction_point && !data.timeout_deduction_point_limit) {
+        this.$notify({type: 'danger', message: '逾期扣分不为0时,扣分上限不能为空'});
+        return;
+      }
+
+      if (this.ahead_timeout(data.ahead_award_point, data.ahead_award_point_limit, '提前奖分', '奖分')) return;
+      if (this.ahead_timeout(data.timeout_deduction_point, data.timeout_deduction_point_limit, '逾期扣分', '扣分')) return;
+
+      let point_limit = this.$userInfo().point_config.point_limit ? this.$userInfo().point_config.point_limit.find(pt => pt.pt_id === 3) : null
+
+      if (!this.$userInfo().is_creator && point_limit) {
+        let entry_limit = Number(point_limit.point);
+        if (entry_limit > 0) {
+          if (data.ahead_award_point > entry_limit || data.timeout_deduction_point > entry_limit) {
+            this.$notify({type: 'danger', message: '每日奖扣分 不能超过您的奖扣分权限(您的奖扣分权限:' + entry_limit + '分)'});
+            return;
+          }
+          if (data.ahead_award_point_limit > entry_limit * 10 || data.timeout_deduction_point_limit > entry_limit * 10) {
+            this.$notify({type: 'danger', message: '奖扣分上限不能超过' + entry_limit * 10 + '分(您的奖扣分权限' + entry_limit + '分*10)'});
+            return;
+          }
+        }
+      }
+
+      let self = this
+      self.$toast.loading({
+        loadingType: 'spinner',
+        forbidClick:true
+      })
+      self.$axiosUser('post', '/api/pro/integral/work/update', data)
+        .then(res => {
+          if (res.data.code !== 1){
+            self.$toast.fail(res.data.msg)
+            return
+          }
+          self.$toast.success(res.data.msg)
+          setTimeout(() => {
+            self.$route_back()
+          },500)
+        })
+        .finally(() => {
+          self.$toast.clear()
+        })
+    }
+  },
+  activated() {
+    this.getInfo()
+  }
+}
+</script>
+
+<style scoped lang="less">
+.content{
+  height: calc(100% - 0.92rem);
+  position: relative;
+  overflow-y: scroll;
+}
+.point-field /deep/ .van-cell__title.van-field__label span {
+  width: 0;
+  color: transparent;
+  height: 0;
+  overflow: hidden;
+  font-size: 0;
+}
+.point-field /deep/ .van-cell__title {
+  width: 0;
+}
+</style>

+ 297 - 70
src/point/view/task/repetitive_tasks_detail.vue

@@ -9,78 +9,243 @@
     </van-nav-bar>
     <div class="body_com has_header">
       <scroller class="scroller-top">
-        <van-cell-group>
-          <div class="flex-box item-box">
-            <div class="laber">任务内容</div>
-            <div class="flex-1">{{info.name}}</div>
-          </div>
-          <div class="flex-box item-box" v-if="info.remark">
-            <div class="laber">任务备注</div>
-            <div class="flex-1">{{info.remark}}</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce">
-            <div class="laber">执行周期</div>
-            <div class="flex-1">{{info.target_info.length>0? '临时任务-':'悬赏任务-'}}{{info.task_cycle_mark}}</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce" v-if="info.point_config.base_point">
-            <div class="laber">任务积分</div>
-            <div class="flex-1">{{info.point_config.base_point}}{{info.pt_name}}</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce">
-            <div class="laber">发布人</div>
-            <div class="flex-1">{{info.owner_name}}</div>
-          </div>
-          <div class="flex-box item-box">
-            <div class="laber">截止时间</div>
-            <div class="flex-1" v-if="info.task_cycle==1">{{info.task_cycle_mark}}{{info.task_cycle_value > 9 ? info.task_cycle_value + ': 00' : '0' + info.task_cycle_value + ': 00'}}点截止</div>
-            <div class="flex-1" v-if="info.task_cycle==2">{{info.task_cycle_mark}}{{weekList[info.task_cycle_value - 1] }}截止</div>
-            <div class="flex-1" v-if="info.task_cycle==3">{{info.task_cycle_mark}}{{info.task_cycle_value}}号截止</div>
-          </div>
-          <div class="flex-box item-box" v-if="info.schedule_expire_time">
-            <div class="laber">有效日期</div>
-            <div class="flex-1">{{info.schedule_expire_time}}</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce">
-            <div class="laber">可见范围</div>
-            <div class="flex-1" v-if="info.department_info.length>0">
-              <span v-for="item in info.department_info" :key="item.id">{{item.name}},</span>
-            </div>
-            <div class="flex-1" v-else>全公司</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce" v-if="info.point_config.ahead_award_point">
-            <div class="laber">提前奖分</div>
-            <div class="flex-1">{{info.point_config.ahead_award_point}}B分/天</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce" v-if="info.point_config.ahead_award_point_limit">
-            <div class="laber">奖分上限</div>
-            <div class="flex-1">{{info.point_config.ahead_award_point_limit}}B分</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce" v-if="info.point_config.timeout_deduction_point">
-            <div class="laber">逾期扣分</div>
-            <div class="flex-1">{{info.point_config.timeout_deduction_point}}B分/天</div>
-          </div>
-          <div class="flex-box item-box flex-v-ce" v-if="info.point_config.timeout_deduction_point_limit">
-            <div class="laber">扣分上限</div>
-            <div class="flex-1">{{info.point_config.timeout_deduction_point_limit}}B分</div>
-          </div>
-
-
-        </van-cell-group>
-        <van-cell-group class="padding-cell-group">
-          <div class="tip">审批人</div>
-          <div style="width:0.9rem; margin-top:0.16rem;">
-              <userImage :user_name="info.reviewer_name" :id="parseInt(info.reviewer_id)"  width="0.8rem" height="0.8rem"  ></userImage>
-            <div style=" font-size: 0.2rem; text-align: center;">{{info.reviewer_name}}</div>
-          </div>
+        <van-cell-group inset>
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template slot="icon">
+              <user-image
+                class="fl"
+                :img_url="info.owner_img_url"
+                :user_name="info.owner_name"
+              />
+            </template>
+            <template slot="title">
+              {{info.owner_name}}&nbsp;
+              {{$getTypesName(info.pt_id)}}{{scheduleTypeMark}}&nbsp;
+            </template>
+            <template slot="default">
+              <van-tag type="primary" size="medium" >{{info.point_config.base_point}}</van-tag>
+            </template>
+          </van-cell>
+          <van-cell
+            :border="false"
+            :title="scheduleTypeMark + '内容'"
+            :value="info.name"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            v-if="info.remark"
+            :border="false"
+            :title="scheduleTypeMark + '备注'"
+            :value="info.remark"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            title="执行周期"
+            :value="`${info.target_info.length > 0 ? '临时任务-' : '悬赏任务-'}${info.task_cycle_mark}`"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.point_config"
+            :title="`${scheduleTypeMark}积分`"
+            :value="`${info.point_config.base_point}${$getTypesName(info.pt_id)}`"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.file_list && info.file_list.length > 0"
+            title="附件"
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template slot="default">
+              <van-image
+                @click="open_img(index)"
+                style="margin-right: 0.1rem"
+                v-for="(item,index) in info.file_list"
+                :key="index"
+                :src="item"
+                width="50"
+                height="50"
+                radius="5"
+                type="contain"
+              />
+            </template>
+          </van-cell>
+          <van-cell
+            :border="false"
+            title="截止时间"
+            :title="expireTimeMark"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.schedule_expire_time"
+            title="有效日期"
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template slot="default">
+              <span v-if="!isExpire(info.schedule_expire_time)">{{info.schedule_expire_time}}</span>
+              <span v-else>
+                <van-tag type="warning" size="medium">{{info.schedule_expire_time}}</van-tag>
+              </span>
+            </template>
+          </van-cell>
+          <van-cell
+            :border="false"
+            v-if="info.department_info"
+            title="可见范围"
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template v-if="info.department_info.length > 0">
+              <span
+                v-for="(item,index) in info.department_info"
+                :key="index"
+              >
+                {{item.name}}&nbsp;
+              </span>
+            </template>
+            <span v-else >全公司</span>
+          </van-cell>
+          <template v-if="info.point_config">
+            <van-cell
+              title="逾期扣分"
+              :value="`${info.point_config.timeout_deduction_point} B分/天`"
+              title-class="align_self"
+              value-class="align_self"
+            />
+            <van-cell
+              title="提前奖分"
+              :value="`${info.point_config.ahead_award_point} B分/天`"
+              title-class="align_self"
+              value-class="align_self"
+            />
+          </template>
         </van-cell-group>
 
-        <van-cell-group class="padding-cell-group" >
-          <div class="tip">执行者</div>
-          <div class="" style="margin-top:0.16rem;display: inline-block;margin-right: 0.2rem; width: 0.8rem;" v-if="info.target_info" v-for="(item,index) in info.target_info" :key="index">
-            <userImage fontSize="0.28" :user_name="item.name" :id="parseInt(item.id)" width="0.8rem" height="0.8rem"></userImage>
-            <div style="font-size: 0.2rem; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">{{item.name}}</div>
-          </div>
+        <van-cell-group inset>
+          <van-cell
+            title="审批人"
+            :value="info.reviewer_name"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            v-if="info.target_info.length > 0"
+            title="执行人"
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template slot="default">
+              <span
+                v-for="(item,index) in info.target_info"
+                :key="index"
+              >
+                {{item.name}}&nbsp;
+              </span>
+            </template>
+          </van-cell>
         </van-cell-group>
+
+        <template v-if="info.item_info">
+          <van-row justify="space-around" class="item-title" >
+            <van-col span="6">规则依据</van-col>
+          </van-row>
+          <van-cell-group
+            :border="false"
+            class="task_detail_group"
+            inset
+          >
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="规则"
+              :value="info.item_info.remark"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="积分"
+              :value="pointRemark"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.item_info.has_delete"
+              :border="false"
+              title="规则状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">规则已删除</van-tag>
+              </template>
+            </van-cell>
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info"
+              :border="false"
+              title="分类"
+              :value="info.rule_info.name"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info && info.rule_info.has_delete"
+              :border="false"
+              title="分类状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">分类已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+
+        <template v-else-if="info.rule_info">
+          <van-row justify="space-around" class="item-title">
+            <van-col span="6" >分类依据</van-col>
+          </van-row>
+          <van-cell-group
+            :border="false"
+            class="task_detail_group"
+            inset
+          >
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="分类"
+              :value="info.rule_info.name"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info.has_delete"
+              :border="false"
+              title="分类状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">分类已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+
+
+
       </scroller>
     </div>
     <van-action-sheet
@@ -116,8 +281,35 @@ export default {
       user_info: this.$userInfo()
     }
   },
+  computed:{
+    scheduleTypeMark(){
+      return !this.info ? '--' : (this.info.type === 2 ? '悬赏' : '任务')
+    },
+    expireTimeMark(){
+      if (!this.info) return '--'
+      let etMark = {
+        1:`${this.info.task_cycle_mark}${this.dayTime(this.info.task_cycle_value)}截止`,
+        2:`${this.info.task_cycle_mark}${this.weekList[this.info.task_cycle_value - 1]}截止`,
+        3:`${this.info.task_cycle_mark}${this.info.task_cycle_value}号截止`,
+      }
+      return etMark[this.info.task_cycle] || '--'
+    },
+    pointRemark(){
+      if (!(this.info && this.info.item_info)) return ''
+      return this.info.item_info.range_type === 1 ? `${this.info.item_info.min_point} ${this.$getTypesName(this.info.item_info.pt_id)}` : `${this.info.item_info.min_point} -- ${this.info.item_info.max_point} ${this.$getTypesName(this.info.item_info.pt_id)}`
+    }
+  },
   // 方法
   methods: {
+    isExpire(expire_time){
+      if (!expire_time) return false
+      let now = new Date()
+      let expire_date = new Date(expire_time)
+      return now >= expire_date
+    },
+    dayTime(item){
+      return item > 9 ? item + ':00' : '0' + item + ':00'
+    },
     // 上拉菜单点击
     sheet_select (action) {
       if (action.name == '删除任务') {
@@ -162,7 +354,7 @@ export default {
       let self = this
       self.showLoading()
       this.$axiosUser('get', '/api/pro/integral/schedule', {schedule_id: self.get_id}).then((res) => {
-        if (res.data.code == '1') {
+        if (res.data.code === 1) {
           self.info = res.data.data
         } else {
           self.$toast(res.data.msg)
@@ -175,6 +367,11 @@ export default {
     }
   },
   mounted () {
+    // console.log('mounted')
+    // this.get_data()
+  },
+  activated() {
+    // console.log('activated')
     this.get_data()
   }
 }
@@ -213,4 +410,34 @@ export default {
   .task_content /deep/ .van-grid-item__content{padding:0;}
 .task_content /deep/ .van-cell__value{text-align: left; color:#323233;}
   .task_content_last{padding-bottom:0.32rem;}
+
+
+.align_self{
+  align-self: center;
+}
+.item-title{
+  text-align: center;
+  margin-top: 10px;
+  font-size: 0.25rem;
+  line-height: 0.5rem;
+  color: #969799;
+}
+.sub-title{
+  font-size: 0.25rem;
+  line-height: 0.25rem;
+  color: #969799;
+}
+.align_self{
+  align-self: center;
+}
+
+.task_detail_group .van-cell {
+  padding: 0.1rem 0.32rem 0.1rem;
+}
+.task_detail_group .name {
+  padding-bottom: 0.2rem;
+}
+.task_detail_group {
+  padding: 0.16rem 0;
+}
 </style>

+ 162 - 12
src/point/view/task/short_task.vue

@@ -19,8 +19,64 @@
         </van-cell-group>
 
         <van-cell-group class="point-field">
+          <van-cell title="积分类型" required id="task_types">
+            <template slot="right-icon">
+              <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
+                <van-radio checked-color class="list" :name="item.id" v-for="(item, index) in point_types" v-if="item.code !== 'JX'" :key="index">{{ item.name }}</van-radio>
+              </van-radio-group>
+              <van-icon class="small_tip" @click="show_small_tip = true" name="question-o" />
+            </template>
+          </van-cell>
+          <van-cell title="指定规则">
+            <template slot="right-icon">
+              <van-radio-group
+                v-model="data.rule_type"
+                direction="horizontal"
+                class="radio_button"
+              >
+                <van-radio class="list" :name="0" >
+                  <span class="rule_type_span">不指定</span>
+                </van-radio>
+                <van-radio class="list" :name="1" >
+                  <span class="rule_type_span">分类</span>
+                </van-radio>
+                <van-radio class="list" :name="2" >
+                  <span class="rule_type_span">规则</span>
+                </van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+
+          <!--     选择分类     -->
+          <CategorySelectorCell
+            v-if="data.rule_type === 1"
+            title="细则分类"
+            v-model="rules"
+            required
+            :pt-id="data.pt_id"
+            :multi="false"
+            scope
+          />
+
+          <!--选择规则  -->
+          <RuleCategorySelectorCell
+            v-if="data.rule_type === 2"
+            :pt-id="data.pt_id"
+            required
+            name="请选择积分规则"
+            title="积分规则"
+            v-model="rule_items"
+            scope
+            :multi="false"
+          >
+            <template slot="label">
+              <span style="color: red">{{ruleItemLabel}}</span>
+            </template>
+          </RuleCategorySelectorCell>
+
+
           <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required></van-cell>
-          <NumberInput v-model="data.base_point" v-validate="'required'" :chosePoint="false" :min="0" :max="100000"></NumberInput>
+          <NumberInput v-model="data.base_point" v-validate="'required'"  :min="minPoint" :max="maxPoint"></NumberInput>
         </van-cell-group>
 
         <van-cell-group>
@@ -35,14 +91,7 @@
             v-model="executor_name"
           ></EmployeeSelectorCell>
           <EmployeeSelectorCell required title="审批人" iconType="records" :show_manager_only="true" v-model="reviewer" v-validate="'required'" name="审批人" :multi="false"></EmployeeSelectorCell>
-          <van-cell title="任务类型" required id="task_types">
-            <template slot="right-icon">
-              <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
-                <van-radio checked-color class="list" :name="item.id" v-for="(item, index) in point_types" v-if="item.code !== 'JX'" :key="index">{{ item.name }}</van-radio>
-              </van-radio-group>
-              <van-icon class="small_tip" @click="show_small_tip = true" name="question-o" />
-            </template>
-          </van-cell>
+
           <van-cell title="重复周期"  @click="show_task_cycle_popup = true">
               <template>
                 <span v-if="data.task_cycle == 0">不重复</span>
@@ -280,7 +329,8 @@
 </template>
 <script>
 import DateTimeCell from '@/components/DateTimeCell';
-
+import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
+import CategorySelectorCell from '@/components/CategorySelectorCell'
 import NumberInput from '@/components/NumberInput';
 import Vue from 'vue';
 import moment from 'moment'
@@ -299,7 +349,9 @@ export default {
     EmployeeSelectorCell,
     Mtextarea,
     DateTimeCell,
-    NumberInput
+    NumberInput,
+    RuleCategorySelectorCell,
+    CategorySelectorCell
   },
   data() {
     let pts = this.$getTypes;
@@ -398,12 +450,29 @@ export default {
       reviewer: [], // 登录员工的信息,
       manage_scope: this.$userInfo().employee_detail.manage_scope,
       pts:pts,
+      rule_items:[],
+      rules:[],
       data: {
+        rule_type:0,
+        rule_id:0,
+        item_id:0,
+        rule_item:{
+          id:0,
+          remark:"",
+          cycle_type: 0,
+          is_attendance: 0,
+          max_point: 0,
+          min_point: 0,
+          prize_type: 0,
+          pt_id: 0,
+          range_type: 0,
+          rule_id: 0,
+        },
         targets: [],
         pt_id: ptB ? ptB.id : 0,
         task_name: '',
         task_remark: '',
-        base_point: 0,
+        base_point: 1,
         expire_time: '',
         package_id: 0,
         weight: 0,
@@ -494,9 +563,78 @@ export default {
       this.data.schedule_expire_date = val ? moment(val).format('YYYY-MM-DD') : '';
       // console.log('任务 ',this.data)
       if (val) this.toast("重复任务将在" + this.data.schedule_expire_date + "停止自动发布")
+    },
+    'data.rule_type'(val){
+      this.initRuleData()
+    },
+    rules(rules){
+      this.data.rule_id = rules.length <= 0 ? 0 : rules[0].id
+    },
+    rule_items(items){
+      this.data.rule_item = items.length <= 0 ? {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      } : {
+        id:items[0].id,
+        remark:items[0].remark,
+        cycle_type: items[0].cycle_type,
+        is_attendance: items[0].is_attendance,
+        max_point: items[0].max_point,
+        min_point: items[0].min_point,
+        prize_type: items[0].prize_type,
+        pt_id: items[0].pt_id,
+        range_type: items[0].range_type,
+        rule_id: items[0].rule_id,
+      }
+      this.data.rule_id = this.data.rule_item.rule_id
+      this.data.item_id = this.data.rule_item.id
+      this.data.base_point = this.data.rule_item.min_point !== 0 ? this.data.rule_item.min_point : 1
+    },
+    'data.pt_id'(val){
+      if (this.data.rule_type === 2) this.initRuleData()
+    }
+  },
+  computed:{
+    ruleItemLabel(){
+      if (this.data.rule_item.id <= 0) return ''
+      let pt = this.pts.find( t => t.id === this.data.rule_item.pt_id)
+      return this.data.rule_item.range_type === 1 ? `${this.data.rule_item.min_point} ${pt.name}` : `${this.data.rule_item.min_point} - ${this.data.rule_item.max_point} ${pt.name}`
+    },
+    minPoint(){
+      return this.data.rule_type !== 2 ? 1 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.min_point)
+    },
+    maxPoint(){
+      return this.data.rule_type !== 2 ? 100000 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.max_point)
     }
   },
   methods: {
+    initRuleData(){
+      this.data.rule_id = 0
+      this.data.item_id = 0
+      this.data.rule_item = {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      }
+      this.data.base_point = 1
+      this.rule_items = []
+      this.rules = []
+    },
     changeunqualified(val) {
       let str = '' + this.data.super_satisfied;
       let str2 = '';
@@ -818,6 +956,18 @@ export default {
     },
     sava_btn() {
       // console.log('任务 save btn',this.data);return;
+      if (this.data.rule_type === 1 && this.data.rule_id <= 0){
+        this.$toast.fail ("请选择规则分类")
+        return
+      }
+      if (this.data.rule_type === 2 && this.data.item_id <= 0){
+        this.$toast.fail('请选择积分规则')
+        return;
+      }
+      if (this.data.base_point <= 0) {
+        this.$toast.fail('积分必须大于0')
+        return;
+      }
       let self = this;
       if (this.data.base_point === 0) {
         self.$notify({ type: 'danger', message: '任务积分不能为0' });

+ 325 - 112
src/point/view/task/taskFile.vue

@@ -8,34 +8,41 @@
 
     <div class="body_com has_header">
       <scroller>
-        <van-cell class="efficiency_list" size="large">
+        <van-cell
+          class="efficiency_list"
+          size="large"
+          :title="info.employee_name"
+        >
           <template slot="icon">
             <userImage :user_name="info.employee_name" :img_url="info.img_url" width="1rem" height="1rem" style="margin-right: 0.12rem;"></userImage>
           </template>
-          <template slot="title">
-            <span>{{ info.employee_name }}</span>
-            <div style="color: #909399;" v-if="info.dept_list.length > 0">
-              <span v-for="(item, index) in info.dept_list" :key="index">
+          <template slot="label">
+            <span v-if="info.dept_list.length > 0" v-for="(item, index) in info.dept_list" :key="index" class="sub-title">
                 <em v-if="index > 0">,</em>
                 {{ item.dept_name }}
               </span>
-            </div>
-            <div style="color: #909399;" v-if="info.dept_list.length == 0">暂无部门</div>
+            <span v-else>暂无部门</span>
           </template>
           <template slot="default">
-            <div style="float: right;text-align: center;padding:0 0.1rem;" v-if="info.status == 4">
+            <div style="float: right;text-align: center;padding:0 0.1rem;" v-if="info.status == 4" class="sub-title">
               <span class="point-span">{{ info.point_config.review_point }}</span>
               <div style="color: #909399;">最终分</div>
             </div>
-
             <div style="float: right;text-align: center;padding:0 0.1rem;">
-              <span class="point-span">{{ info.point_config.base_point }}</span>
-              <div style="color: #909399;">{{ info.pt_name }}</div>
+              <span class="point-span">{{ `${info.point_config.base_point} ${info.pt_name}` }}</span>
             </div>
           </template>
         </van-cell>
-        <van-cell-group :border="false" class="task_detail_group" v-if="info.review_status === 2">
-          <van-cell :border="false">
+        <van-cell-group
+          :border="false"
+          class="task_detail_group"
+          v-if="info.review_status === 2"
+        >
+          <van-cell
+            :border="false"
+            title-class="align_self"
+            value-class="align_self"
+          >
             <template slot="title">
               <div class="time">
                 <span>审批结果</span>
@@ -43,7 +50,11 @@
               </div>
             </template>
           </van-cell>
-          <van-cell :border="false">
+          <van-cell
+            :border="false"
+            title-class="align_self"
+            value-class="align_self"
+          >
             <template slot="title">
               <div class="time">
                 <span>驳回理由</span>
@@ -53,106 +64,283 @@
           </van-cell>
         </van-cell-group>
 
-        <van-cell-group :border="false" class="task_detail_group">
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>工作内容</span>
-                <span class="timeExactly" style="white-space: pre-line;">{{ info.task_name }}</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>发布时间</span>
-                <span class="timeExactly">{{ info.create_time }}</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>截止时间</span>
-                <span class="timeExactly">{{ info.expire_time }}</span>
-                <span style="padding-left: 10px;" class="red" v-show="info.expire_day > 0">逾期{{ info.expire_day }}天</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell v-if="info.point_config.ahead_award_point * 1 > 0" :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>提前奖分</span>
-                <span class="timeExactly">{{ info.point_config.ahead_award_point }}分/天</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell v-if="info.point_config.timeout_deduction_point * 1 > 0" :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>逾期扣分</span>
-                <span class="timeExactly">{{ info.point_config.timeout_deduction_point }}分/天</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>任务备注</span>
-                <span class="timeExactly" style="white-space: pre-line;">{{ info.task_remark }}</span>
-              </div>
+        <van-row justify="space-around" class="item-title">
+          <van-col span="6" >任务信息</van-col>
+        </van-row>
+        <van-cell-group
+          :border="false"
+          class="task_detail_group"
+          inset
+        >
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="审批人"
+            :value="info.reviewer_name"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="发布人"
+            :value="info.publisher_name"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="任务积分"
+            :value="`${info.point_config.base_point} ${info.pt_name || ''}`"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="内容"
+            :value="info.task_name"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            v-if="info.task_remark"
+            :border="false"
+            title="任务备注"
+            :value="info.task_remark"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="发布时间"
+            :value="info.create_time"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            v-if="info.point_config.review_point"
+            :border="false"
+            title="最终分"
+            :value="info.point_config.review_point"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            :border="false"
+            title="截止时间"
+          >
+            <template slot="default">
+              {{ info.expire_time }} <span style="padding-left: 10px;" class="red" v-show="info.expire_day > 0">逾期{{ info.expire_day }}天</span>
             </template>
           </van-cell>
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            v-if="info.point_config.timeout_deduction_point > 0"
+            :border="false"
+            title="逾期扣分"
+            :value="`${info.point_config.timeout_deduction_point} B分/天`"
+          />
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            v-if="info.point_config.ahead_award_point > 0"
+            :border="false"
+            title="提前奖分"
+            :value="`${info.point_config.ahead_award_point} B分/天`"
+          />
 
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>审批人</span>
-                <span class="timeExactly">{{ info.reviewer_name }}</span>
-              </div>
-            </template>
-          </van-cell>
-          <van-cell :border="false" v-if="info.review_remark">
-            <template slot="title">
-              <div class="time">
-                <span>审批意见</span>
-                <span class="timeExactly" style="white-space: pre-line;">{{ info.review_remark }}</span>
-              </div>
-            </template>
-          </van-cell>
 
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>发布人</span>
-                <span class="timeExactly">{{ info.publisher_name }}</span>
-              </div>
-            </template>
-          </van-cell>
 
-          <van-cell :border="false">
-            <template slot="title">
-              <div class="time">
-                <span>积分种类</span>
-                <span class="timeExactly">{{ info.pt_name }}</span>
-              </div>
-            </template>
-          </van-cell>
 
-          <van-cell :border="false" v-if="info.task_file_list.length != 0">
-            <template slot="title">
-              <div class="time">
-                <span>任务图片</span>
-                <span>
-                  <van-image v-for="(items, index) in info.task_file_list" :key="index" @click="open_image(info.task_file_list)" width="45" height="45" radius="3" :src="items" />
-                </span>
-              </div>
-            </template>
-          </van-cell>
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>发布时间</span>-->
+<!--                <span class="timeExactly">{{ info.create_time }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>截止时间</span>-->
+<!--                <span class="timeExactly">{{ info.expire_time }}</span>-->
+<!--                <span style="padding-left: 10px;" class="red" v-show="info.expire_day > 0">逾期{{ info.expire_day }}天</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+<!--          <van-cell v-if="info.point_config.ahead_award_point * 1 > 0" :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>提前奖分</span>-->
+<!--                <span class="timeExactly">{{ info.point_config.ahead_award_point }}分/天</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+<!--          <van-cell v-if="info.point_config.timeout_deduction_point * 1 > 0" :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>逾期扣分</span>-->
+<!--                <span class="timeExactly">{{ info.point_config.timeout_deduction_point }}分/天</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>任务备注</span>-->
+<!--                <span class="timeExactly" style="white-space: pre-line;">{{ info.task_remark }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>审批人</span>-->
+<!--                <span class="timeExactly">{{ info.reviewer_name }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+<!--          <van-cell :border="false" v-if="info.review_remark">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>审批意见</span>-->
+<!--                <span class="timeExactly" style="white-space: pre-line;">{{ info.review_remark }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>发布人</span>-->
+<!--                <span class="timeExactly">{{ info.publisher_name }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+
+<!--          <van-cell :border="false">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>积分种类</span>-->
+<!--                <span class="timeExactly">{{ info.pt_name }}</span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
+
+<!--          <van-cell :border="false" v-if="info.task_file_list.length != 0">-->
+<!--            <template slot="title">-->
+<!--              <div class="time">-->
+<!--                <span>任务图片</span>-->
+<!--                <span>-->
+<!--                  <van-image v-for="(items, index) in info.task_file_list" :key="index" @click="open_image(info.task_file_list)" width="45" height="45" radius="3" :src="items" />-->
+<!--                </span>-->
+<!--              </div>-->
+<!--            </template>-->
+<!--          </van-cell>-->
         </van-cell-group>
 
-        <van-cell-group class="point" v-if="info.point_config.standard && info.point_config.standard.super_satisfied * 1 > 0">
-          <van-cell v-if="info.point_config.standard" title="评分标准">
+
+
+        <template v-if="info.item_info">
+          <van-row justify="space-around" class="item-title">
+            <van-col span="6" >规则依据</van-col>
+          </van-row>
+          <van-cell-group
+            :border="false"
+            class="task_detail_group"
+            inset
+          >
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="规则"
+              :value="info.item_info.remark"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="积分"
+              :value="pointRemark"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.item_info.has_delete"
+              :border="false"
+              title="规则状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">规则已删除</van-tag>
+              </template>
+            </van-cell>
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info"
+              :border="false"
+              title="分类"
+              :value="info.rule_info.name"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info && info.rule_info.has_delete"
+              :border="false"
+              title="分类状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">分类已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+
+        <template v-else-if="info.rule_info">
+          <van-row justify="space-around" class="item-title">
+            <van-col span="6" >分类依据</van-col>
+          </van-row>
+          <van-cell-group
+            :border="false"
+            class="task_detail_group"
+            inset
+          >
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              :border="false"
+              title="分类"
+              :value="info.rule_info.name"
+            />
+            <van-cell
+              title-class="align_self"
+              value-class="align_self"
+              v-if="info.rule_info.has_delete"
+              :border="false"
+              title="分类状态"
+            >
+              <template slot="default">
+                <van-tag type="warning">分类已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+
+        <van-cell-group
+          class="point"
+          v-if="info.point_config.standard && info.point_config.standard.super_satisfied * 1 > 0"
+          inset
+        >
+          <van-cell
+            title-class="align_self"
+            value-class="align_self"
+            v-if="info.point_config.standard"
+            title="评分标准"
+          >
             <template slot="label">
               <van-grid slot="label" :border="false">
                 <van-grid-item text="超预期">
@@ -340,7 +528,7 @@ export default {
       active: 0,
       numberslider: 0,
       active1: 'running',
-      title: '工作详情',
+      title: '任务详情',
       filter: {
         page: 1,
         type: 'all',
@@ -370,7 +558,11 @@ export default {
         status_mark: '',
         task_file_list: [],
         task_name: '',
-        task_remark: ''
+        task_remark: '',
+        rule_id:0,
+        rule_info:{},
+        item_id:0,
+        item_info:{}
       },
       process: [],
       checked: false,
@@ -404,6 +596,7 @@ export default {
   },
   activated() {
   	if (this.$route.query.task_id) {
+      this.info.id = this.$route.query.task_id
   	  this.getList()
   	}
     if(this.$route.query.isHome){
@@ -435,7 +628,7 @@ export default {
     },
 
     sheet_select (action, index) {
-      if (action.name == '编辑任务') {
+      if (action.name == '更新任务') {
         if (this.$route.query.isJx) {
           // 编辑 从上一个页面传过来一些参数
           this.$router.push({
@@ -447,7 +640,8 @@ export default {
             }
           })
         } else {
-          this.$router.push({ name: 'compile_task', query: { info: JSON.stringify(this.info) } })
+          this.$router.push({name:'WorkEdit',params:{workId:this.$route.query.task_id.toString()}})
+          // this.$router.push({ name: 'compile_task', query: { info: JSON.stringify(this.info) } })
         }
       }
       if (action.name == '撤销任务') {
@@ -538,10 +732,10 @@ export default {
       // 这里比较复杂,因为团队绩效的工作详情跟我的发布的工作详情都调用这个页面
       if (data.status == 1) {
         if (data.pt_id != 1) {
-          this.actions.push({ name: '编辑任务' })
+          this.actions.push({ name: '更新任务' })
           this.actions.push({ name: '删除任务' })
         } else if (data.pt_id == 1 && this.$route.query.isJx) {
-          this.actions.push({ name: '编辑任务' })
+          this.actions.push({ name: '更新任务' })
           this.actions.push({ name: '删除任务' })
         } else {
           this.actions.push({ name: '删除任务' })
@@ -636,6 +830,10 @@ export default {
   computed:{
     canUpdate(){
       return this.info.employee_id === this.userInfo.id && [1,6].includes(this.info.status)
+    },
+    pointRemark(){
+      if (!(this.info && this.info.item_info)) return ''
+      return this.info.item_info.range_type === 1 ? `${this.info.item_info.min_point} ${this.$getTypesName(this.info.item_info.pt_id)}` : `${this.info.item_info.min_point} -- ${this.info.item_info.max_point} ${this.$getTypesName(this.info.item_info.pt_id)}`
     }
   },
   mounted () {
@@ -898,4 +1096,19 @@ export default {
   -webkit-transform: scale(0.5);
   transform: scale(0.5);
 }
+.item-title{
+  text-align: center;
+  margin-top: 10px;
+  font-size: 0.25rem;
+  line-height: 0.5rem;
+  color: #969799;
+}
+.sub-title{
+  font-size: 0.25rem;
+  line-height: 0.25rem;
+  color: #969799;
+}
+.align_self{
+  align-self: center;
+}
 </style>

+ 180 - 43
src/point/view/task/task_detail_a.vue

@@ -10,7 +10,10 @@
     <div class="body_com has_header">
       <scroller v-if="info.point_config">
 
-        <van-cell-group class="task_detail_list_box">
+        <van-cell-group
+          class="task_detail_list_box"
+          inset
+        >
           <van-cell v-show="info.status == 1||info.status == 4" :title="info.owner_name+`悬赏的${$getTypesName(info.pt_id)}任务`">
             <template slot="label">
               <span class="orange">{{info.status_mark}}</span>
@@ -20,52 +23,169 @@
               <userImage v-show="info.receiver_id == 0" class="fl"  :img_url="info.owner_img_url" :user_name="info.owner_name"  style="margin-right: 0.2rem"></userImage>
             </template>
             <template slot="right-icon">
-              <span class="point red" v-if="info.point_config.base_point> 0">+{{info.point_config.base_point}}{{info.pt_name}}</span>
+              <span class="point red" v-if="info.point_config.base_point > 0">+{{info.point_config.base_point}}{{info.pt_name}}</span>
               <span class="point green" v-if="info.point_config.base_point< 0">{{info.point_config.base_point}}{{info.pt_name}}</span>
             </template>
           </van-cell>
 
-          <van-cell v-show="info.status == 2||info.status == 3" :title="info.receiver_name+`领取的${$getTypesName(info.pt_id)}任务`" title-class="head" label-class="sign">
-            <template slot="label">
-              <span class="orange">{{info.status_mark}}</span>
-            </template>
-            <template slot="icon">
-              <userImage v-show="info.receiver_id != 0" class="fl"  :img_url="info.receiver_img_url" :user_name="info.receiver_name"  style="margin-right: 0.2rem"></userImage>
-              <userImage v-show="info.receiver_id == 0" class="fl"  :img_url="info.owner_img_url" :user_name="info.owner_name"  style="margin-right: 0.2rem"></userImage>
-            </template>
-            <template slot="right-icon">
-             <span class="point red" v-if="info.point_config.base_point> 0">+{{info.point_config.base_point}}{{$getTypesName(info.pt_id)}}</span>
-             <span class="point green" v-if="info.point_config.base_point< 0">{{info.point_config.base_point}}{{$getTypesName(info.pt_id)}}</span>
-            </template>
-          </van-cell>
-
-          <van-cell :border="false" :title="info.task_name" title-class="task_name" style="margin-top:0.24rem;"></van-cell>
-          <van-cell :border="false" title="任务备注" v-if="info.task_remark != ''" title-class="title fontColorC task_detail" value-class="text-left" :value="info.task_remark"></van-cell>
-          <van-cell :border="false" title="任务类型" title-class="title fontColorC" value-class="text-left">{{info.type_mark}}</van-cell>
-          <van-cell :border="false" title="积分类型" title-class="title fontColorC" value-class="text-left">{{$getTypesName(info.pt_id)}}</van-cell>
-          <van-cell :border="false" title="发布时间" title-class="title fontColorC" value-class="text-left">{{info.create_time}}</van-cell>
-          <van-cell :border="false" title="截止时间" title-class="title fontColorC" value-class="text-left">{{info.end_time}}</van-cell>
-          <van-cell :border="false" title="审批人" title-class="title fontColorC" value-class="text-left" >{{info.reviewer_name}}</van-cell>
-          <van-cell :border="false" title="发布人" title-class="title fontColorC" value-class="text-left" >{{info.owner_name}}</van-cell>
-
-
-<!--          <van-cell :border="false" title="提前奖分" title-class="title fontColorC task_delayrecord" value-class="text-left" :value="info.point_config.ahead_award_point+'分/天'" v-if="info.point_config.ahead_award_point"></van-cell>
-          <van-cell :border="false" title="逾期扣分" title-class="title fontColorC task_delayrecord" value-class="text-left" :value="info.point_config.timeout_deduction_point+'分/天'" v-if="info.point_config.timeout_deduction_point"></van-cell> -->
-
-
-          <van-cell v-if="info.department_info.length > 0" title="可见范围" title-class="title fontColorC task_delayrecord" value-class="text-left">
-            <template  slot="default">
-               <span v-for="(items,index) in info.department_info" :key="index">
-                  {{items.name}}
+          <van-cell
+            :border="false"
+            title="任务内容"
+            :value="info.task_name"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.receiver_id !== 0"
+            :title="info.status === 3 ? '完成人' : '领取人'"
+            :value="info.receiver_name"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.task_remark"
+            title="任务备注"
+            :value="info.task_remark"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.point_config"
+            title="任务积分"
+            :value="info.point_config.base_point + $getTypesName(info.pt_id)"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            title="发布时间"
+            :value="info.create_time"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            title="截止时间"
+            :value="info.end_time"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.point_config"
+            title="逾期扣分"
+            :value="`${info.point_config.timeout_deduction_point}/分`"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.point_config && info.point_config.ahead_award_point"
+            title="提前奖分"
+            :value="`${info.point_config.ahead_award_point}/分`"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            :border="false"
+            v-if="info.department_info"
+            title="可见范围"
+            title-class="align_self"
+            value-class="align_self"
+          >
+            <template slot="default">
+              <template v-if="info.department_info.length > 0">
+                <span
+                  v-for="(item,index) in info.department_info"
+                  :key="index"
+                >
+                  {{item.name}}&nbsp;
                 </span>
+              </template>
+              <span v-else>全公司可见</span>
             </template>
           </van-cell>
-          <van-cell title="图片" title-class="title fontColorC task_img" value-class="text-left" v-show="info.task_file_list.length > 0">
+          <van-cell
+            :border="false"
+            title="任务类型"
+            :value="info.source_type_mark"
+            title-class="align_self"
+            value-class="align_self"
+          />
+          <van-cell
+            title="图片"
+            title-class="title fontColorC task_img align_self"
+            value-class="text-left align_self"
+            v-show="info.task_file_list.length > 0"
+          >
             <template slot="default">
               <van-image @click="open_img(index)" style="margin-right: 0.1rem" v-for="(item,index) in info.task_file_list" :key="index" :src="item" width="50" height="50" radius="5" type="contain"  />
             </template>
           </van-cell>
         </van-cell-group>
+
+        <template v-if="info.item_info">
+          <van-row justify="space-around" class="item-title">
+            <van-col span="6" >规则依据</van-col>
+          </van-row>
+          <van-cell-group inset>
+            <van-cell
+              :border="false"
+              title="规则"
+              :value="info.item_info.remark"
+              title-class="align_self"
+              value-class="align_self"
+            >
+              <template slot="default">
+                {{info.item_info.remark}}
+                <van-tag v-if="info.item_info.has_delete" type="warning" size="medium">已删除</van-tag>
+              </template>
+            </van-cell>
+            <van-cell
+              :border="false"
+              title="积分"
+              :value="pointRemark"
+              title-class="align_self"
+              value-class="align_self"
+            />
+            <van-cell
+              v-if="info.rule_info"
+              :border="false"
+              title="分类"
+              :value="info.rule_info.name"
+              title-class="align_self"
+              value-class="align_self"
+            >
+              <template slot="default">
+                {{info.rule_info.name}}
+                <van-tag v-if="info.rule_info.has_delete" type="warning" size="medium">已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+        <template v-else-if="info.rule_info">
+          <van-row justify="space-around" class="item-title">
+            <van-col span="6" >分类依据</van-col>
+          </van-row>
+          <van-cell-group inset>
+            <van-cell
+              :border="false"
+              title="分类"
+              title-class="align_self"
+              value-class="align_self"
+            >
+              <template slot="default">
+                {{info.rule_info.name}}
+                <van-tag v-if="info.rule_info.has_delete" type="warning" size="medium">已删除</van-tag>
+              </template>
+            </van-cell>
+          </van-cell-group>
+        </template>
+
+
         <div class="confirm_buttom" style="padding: 0.32rem" v-show="info.status == '1' && shoe_btn && user_id != info.owner_id && info.reviewer_id != user_id && !isCreator">
           <van-button type="info" block @click="receive_tasks">领取任务</van-button>
         </div>
@@ -95,7 +215,7 @@ export default {
       The_current_account: false,
       actions: [],
       sheet_show: false,
-      title: '任务详情',
+      title: '悬赏信息',
       info: {
         point_config:{},
         department_info:[],
@@ -108,17 +228,24 @@ export default {
       isCreator: this.$userInfo().is_creator,
     }
   },
+  computed:{
+    pointRemark(){
+      if (!(this.info && this.info.item_info)) return ''
+      return this.info.item_info.range_type === 1 ? `${this.info.item_info.min_point} ${this.$getTypesName(this.info.item_info.pt_id)}` : `${this.info.item_info.min_point} -- ${this.info.item_info.max_point} ${this.$getTypesName(this.info.item_info.pt_id)}`
+    }
+  },
   // 方法
   methods: {
     // 删除
     sheet_select (action) {
-      if (action.name == '编辑任务') {
-        this.$router.push({name: 'compile_temp_task', query: {info: JSON.stringify(this.info)}})
+      if (action.name == '更新悬赏') {
+        // this.$router.push({name: 'compile_temp_task', query: {info: JSON.stringify(this.info)}})
+        this.$router.push({name: 'TaskEdit', params: {taskId: this.$route.query.task_id.toString()}})
       }
-      if (action.name == '删除任务') {
+      if (action.name == '删除悬赏') {
         this.$dialog.confirm({
-          title: '删除任务',
-          message: '删除此任务将会删除其相关记录和积分数据,确认删除吗?'
+          title: '删除悬赏',
+          message: '删除此悬赏将会删除其相关记录和积分数据,确认删除吗?'
         }).then(() => {
           this.delete_task()
         })
@@ -170,9 +297,9 @@ export default {
           self.info = res.data.data
           self.shoe_btn = moment(this.time) < moment(this.info.expire_time)
           if (self.info.status == 1 && self.info.status_mark == '待领取') {
-            self.actions = [{name: '编辑任务'}, { name: '删除任务' }]
+            self.actions = [{name: '更新悬赏'}, { name: '删除悬赏' }]
           } else {
-            self.actions = [{ name: '删除任务' }]
+            self.actions = [{ name: '删除悬赏' }]
           }
         } else {
           self.$toast(res.data.msg)
@@ -258,4 +385,14 @@ export default {
 .task_detail_box .task_detail_list_box{
   padding:0.32rem 0;
 }
+.item-title{
+  text-align: center;
+  margin-top: 10px;
+  font-size: 0.25rem;
+  line-height: 0.5rem;
+  color: #969799;
+}
+.align_self{
+  align-self: center;
+}
 </style>

+ 174 - 22
src/point/view/task/temp_task.vue

@@ -15,12 +15,73 @@
               :imgs_max="3"
               images
               :imgs.sync="data.file_list"
-            ></Mtextarea>
+            />
           </van-cell>
         </van-cell-group>
         <van-cell-group class="point-field">
+          <van-cell title="积分类型" required>
+            <template slot="right-icon">
+              <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
+                <van-radio class="list" :class="{ changeRadio: item.id === data.pt_id }" v-if="item.code !== 'JX'" :name="item.id" v-for="(item, index) in pts" :key="index">
+                  {{ item.name }}
+                </van-radio>
+              </van-radio-group>
+<!--              <smallTip icon="question-o" position="30%">-->
+<!--                <p style="margin: 0; line-height: 0.6rem">A分:物质分,与钱直接挂钩</p>-->
+<!--                <p style="margin: 0; line-height: 0.6rem">B分:福利分,与福利待遇挂钩</p>-->
+<!--                <p style="margin: 0; line-height: 0.6rem">绩效分:工作分,与绩效考核挂钩</p>-->
+<!--              </smallTip>-->
+            </template>
+          </van-cell>
+          <van-cell title="指定规则">
+            <template slot="right-icon">
+              <van-radio-group
+                v-model="data.rule_type"
+                direction="horizontal"
+                class="radio_button"
+              >
+                <van-radio class="list" :name="0" >
+                  <span class="rule_type_span">不指定</span>
+                </van-radio>
+                <van-radio class="list" :name="1" >
+                  <span class="rule_type_span">分类</span>
+                </van-radio>
+                <van-radio class="list" :name="2" >
+                  <span class="rule_type_span">规则</span>
+                </van-radio>
+              </van-radio-group>
+            </template>
+          </van-cell>
+<!--     选择分类     -->
+          <CategorySelectorCell
+            v-if="data.rule_type === 1"
+            title="细则分类"
+            v-model="rules"
+            required
+            :pt-id="data.pt_id"
+            :multi="false"
+            scope
+          />
+
+
+          <!--选择规则  -->
+          <RuleCategorySelectorCell
+            v-if="data.rule_type === 2"
+            :pt-id="data.pt_id"
+            required
+            name="请选择积分规则"
+            title="积分规则"
+            v-model="rule_items"
+            scope
+            :multi="false"
+          >
+            <template slot="label">
+              <span style="color: red">{{ruleItemLabel}}</span>
+            </template>
+          </RuleCategorySelectorCell>
+
           <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required />
-          <NumberInput v-model="data.base_point" v-validate="'required'" :chosePoint="false" :min="0" :max="100000"></NumberInput>
+          <NumberInput v-model="data.base_point" v-validate="'required'" :min="minPoint" :max="maxPoint"/>
         </van-cell-group>
 
         <van-cell-group>
@@ -34,20 +95,6 @@
             v-model="reviewer"
             :multi="false"
           ></EmployeeSelectorCell>
-          <van-cell title="任务类型" required>
-            <template slot="right-icon">
-              <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
-                <van-radio class="list" :class="{ changeRadio: item.id === data.pt_id }" v-if="item.code !== 'JX'" :name="item.id" v-for="(item, index) in pts" :key="index">
-                  {{ item.name }}
-                </van-radio>
-              </van-radio-group>
-              <smallTip icon="question-o" position="30%">
-                <p style="margin: 0; line-height: 0.6rem">A分:物质分,与钱直接挂钩</p>
-                <p style="margin: 0; line-height: 0.6rem">B分:福利分,与福利待遇挂钩</p>
-                <p style="margin: 0; line-height: 0.6rem">绩效分:工作分,与绩效考核挂钩</p>
-              </smallTip>
-            </template>
-          </van-cell>
           <van-cell title="重复周期"  @click="show_task_cycle_popup = true">
               <template>
                 <span v-if="data.task_cycle == 0">不重复</span>
@@ -278,7 +325,8 @@
 <script>
 import DeptSelectorCell from '@/components/DeptSelectorCell';
 import DateTimeCell from '@/components/DateTimeCell';
-
+import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
+import CategorySelectorCell from '@/components/CategorySelectorCell'
 import NumberInput from '@/components/NumberInput';
 import Vue from 'vue';
 import moment from 'moment'
@@ -368,12 +416,29 @@ export default {
       ],
       reviewer: reviewer,
       pts: pts,
+      rule_items:[],
+      rules:[],
       data: {
+        rule_type:0,
+        rule_id:0,
+        item_id:0,
+        rule_item:{
+          id:0,
+          remark:"",
+          cycle_type: 0,
+          is_attendance: 0,
+          max_point: 0,
+          min_point: 0,
+          prize_type: 0,
+          pt_id: 0,
+          range_type: 0,
+          rule_id: 0,
+        },
         task_type: 1,
         pt_id: ptB ? ptB.id : 0,
         task_name: '',
         task_remark: '',
-        base_point: 0,
+        base_point: 1,
         expire_time: '',
         file_list: [],
         reviewer_id: this.$userInfo().id,
@@ -408,7 +473,9 @@ export default {
     DateTimeCell,
     DeptSelectorCell,
     smallTip,
-    NumberInput
+    NumberInput,
+    RuleCategorySelectorCell,
+    CategorySelectorCell,
   },
   watch: {
     'data.task_cycle': function(val) {
@@ -446,6 +513,56 @@ export default {
       this.data.schedule_expire_date = val ? moment(val).format('YYYY-MM-DD') : '';
       // console.log('悬赏',this.data);
       if (val) this.$toast("重复悬赏将在" + this.data.schedule_expire_date + "停止自动发布")
+    },
+    'data.rule_type'(val){
+      this.initRuleData()
+    },
+    rules(rules){
+      this.data.rule_id = rules.length <= 0 ? 0 : rules[0].id
+    },
+    rule_items(items){
+      this.data.rule_item = items.length <= 0 ? {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      } : {
+        id:items[0].id,
+        remark:items[0].remark,
+        cycle_type: items[0].cycle_type,
+        is_attendance: items[0].is_attendance,
+        max_point: items[0].max_point,
+        min_point: items[0].min_point,
+        prize_type: items[0].prize_type,
+        pt_id: items[0].pt_id,
+        range_type: items[0].range_type,
+        rule_id: items[0].rule_id,
+      }
+      this.data.rule_id = this.data.rule_item.rule_id
+      this.data.item_id = this.data.rule_item.id
+      this.data.base_point = this.data.rule_item.min_point !== 0 ? this.data.rule_item.min_point : 1
+    },
+    'data.pt_id'(val){
+      if (this.data.rule_type === 2) this.initRuleData()
+    }
+  },
+  computed:{
+    ruleItemLabel(){
+      if (this.data.rule_item.id <= 0) return ''
+      let pt = this.pts.find( t => t.id === this.data.rule_item.pt_id)
+      return this.data.rule_item.range_type === 1 ? `${this.data.rule_item.min_point} ${pt.name}` : `${this.data.rule_item.min_point} - ${this.data.rule_item.max_point} ${pt.name}`
+    },
+    minPoint(){
+      return this.data.rule_type !== 2 ? 1 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.min_point)
+    },
+    maxPoint(){
+      return this.data.rule_type !== 2 ? 100000 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.max_point)
     }
   },
   methods: {
@@ -624,6 +741,25 @@ export default {
         this.$toast.clear();
       });
     },
+    initRuleData(){
+      this.data.rule_id = 0
+      this.data.item_id = 0
+      this.data.rule_item = {
+        id:0,
+        remark:"",
+        cycle_type: 0,
+        is_attendance: 0,
+        max_point: 0,
+        min_point: 0,
+        prize_type: 0,
+        pt_id: 0,
+        range_type: 0,
+        rule_id: 0,
+      }
+      this.data.base_point = 1
+      this.rule_items = []
+      this.rules = []
+    },
     initData(){
       this.reviewer = [];
       this.data = {
@@ -631,7 +767,7 @@ export default {
         pt_id: 0,
         task_name: '',
         task_remark: '',
-        base_point: 0,
+        base_point: 1,
         expire_time: '',
         file_list: [],
         reviewer_id: 0,
@@ -662,13 +798,25 @@ export default {
     },
     sava_btn() {
       // console.log('悬赏 sava_btn',this.data);return;
+      if (this.data.rule_type === 1 && this.data.rule_id <= 0){
+        this.$toast.fail ("请选择规则分类")
+        return
+      }
+      if (this.data.rule_type === 2 && this.data.item_id <= 0){
+        this.$toast.fail('请选择积分规则')
+        return;
+      }
+      if (this.data.base_point <= 0) {
+        this.$toast.fail('积分必须大于0')
+        return;
+      }
       let self = this;
       self.$validator.validate().then(result => {
         if (!result) {
           self.$notify({ type: 'danger', message: self.$validator.errors.items[0].msg });
         } else {
-          if (self.data.base_point == 0) {
-            self.$notify({ type: 'danger', message: '任务积分必须大约0' });
+          if (self.data.base_point === 0) {
+            self.$notify({ type: 'danger', message: '任务积分不能为0' });
           } else {
             self.sub();
           }
@@ -828,4 +976,8 @@ export default {
 .temp_task_box .small_tip_content p:nth-child(3) {
   display: none;
 }
+.rule_type_span {
+  font-size: 0.25rem;
+  line-height: 0.5rem;
+}
 </style>

+ 16 - 0
src/router/pointRoute.js

@@ -491,6 +491,22 @@ const routes = [
     component: () => import('@/point/view/integral/appealList'),
     label: '申诉列表',
     need_login: true
+  },
+  {
+    path:'/work/edit/:workId',
+    name:'WorkEdit',
+    component: () => import('@/point/view/task/WorkEdit'),
+    label: '任务编辑',
+    need_login: true,
+    props:true
+  },
+  {
+    path: '/task/edit/:taskId',
+    name: 'TaskEdit',
+    component: () => import("@/point/view/task/TaskEdit"),
+    label: '悬赏编辑',
+    need_login: true,
+    props: true
   }
 ]
 export default routes

+ 1 - 1
src/utils/helper.js

@@ -1,3 +1,3 @@
 export function specialFilter(inputStr){
-  return inputStr.replace(/[^(\w\d\s\u4e00-\u9fa5:、,.!@$#%*{}<>+=?\-\(\)\[\])]/g,"")
+  return inputStr.replace(/[^(\w\d\s\u4e00-\u9fa5+:、,.!@$#%*={}:,。!()【】《》;¥?’”\-\(\)\[\])]/g,"")
 }