diff --git a/src/pages/plan/list/list.js b/src/pages/plan/list/list.js index d5a9a3f9..e5a58d68 100644 --- a/src/pages/plan/list/list.js +++ b/src/pages/plan/list/list.js @@ -16,7 +16,8 @@ import { DropdownContent, Menu, Sweetalert, - Pop + Pop, + Select } from "zent" import "@/assets/comm.css" import Ipt from "@/components/input/main" @@ -34,11 +35,18 @@ import { getReseller, dingTaskQuery } from "@/assets/api.js" -import { omitBy, isNaN, isNil, findIndex } from "lodash-es" +import { findIndex, pickBy } from "lodash-es" import menu from "@/assets/enum.js" var QRCode = require("qrcode.react") const Column = [ + { + title: "计划 ID", + name: "id", + prop: "id", + type: "normal", + width: "auto" + }, { title: "营销计划名称", name: "title", @@ -144,6 +152,24 @@ const Column = [ } ] +export const options = [ + { + key: "id", + text: "计划ID", + placeholder: "请输入计划ID查询" + }, + { + key: "title", + text: "计划名称", + placeholder: "请输入计划名称查询" + }, + { + key: "reseller_name", + text: "分销商名称", + placeholder: "请输入分销商名称查询" + } +] + export default class acclist extends React.Component { constructor(props) { super(props) @@ -180,6 +206,8 @@ export default class acclist extends React.Component { email_radio: -1, phone_radio: -1, key_word: "", + searchOption: undefined, + placeholder: "", audit_visible: false, cur_item: null, @@ -256,10 +284,7 @@ export default class acclist extends React.Component { } getPlanList(data) { - let queryParams = omitBy(data, (value) => { - return isNaN(value) || isNil(value) - }) - getPlanList(queryParams).then((res) => { + getPlanList(pickBy(data)).then((res) => { handelResponse( res, (req, msg) => { @@ -284,11 +309,10 @@ export default class acclist extends React.Component { let data = { page: this.state.page, limit: this.state.limit, - status: this.state.status, - key_word: this.state.key_word + status: this.state.status } - if (data.key_word === "") { - delete data.key_word + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } this.getPlanList(data) } @@ -359,8 +383,10 @@ export default class acclist extends React.Component { let data = { page: this.state.page, limit: this.state.limit, - status: this.state.status, - key_word: this.state.key_word + status: this.state.status + } + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } self.getPlanList(data) Notify.success("更改状态成功") @@ -386,8 +412,10 @@ export default class acclist extends React.Component { let data = { page: this.state.page, limit: this.state.limit, - status: this.state.status, - key_word: this.state.key_word + status: this.state.status + } + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } self.getPlanList(data) Notify.success("更改状态成功") @@ -504,11 +532,10 @@ export default class acclist extends React.Component { let data = { page: 1, limit: 10, - status: this.state.status, - key_word: this.state.key_word + status: this.state.status } - if (data.key_word === "") { - delete data.key_word + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } self.getPlanList(data) }, @@ -564,8 +591,10 @@ export default class acclist extends React.Component { this.setState({ limit: 10, page: 1 }) let data = { page: 1, - limit: 10, - key_word: this.state.key_word + limit: 10 + } + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } data[prop] = e if (e == 999) { @@ -589,20 +618,26 @@ export default class acclist extends React.Component { // 监听组件内部状态的变化: componentDidUpdate(prevProps, prevState) { // 参数分别为改变之前的数据状态对象 + if (prevState.key_word != this.state.key_word && !this.state.key_word) { + this.iptSureFn() + } - if (prevState.key_word != this.state.key_word && prevState.status != this.state.status) { - this.iptsureFn() + if (prevState.searchOption != this.state.searchOption && !this.state.searchOption) { + this.iptSureFn() + this.setState({ key_word: "" }) } } - iptsureFn(e) { + iptSureFn(e) { this.setState({ page: 1 }) this.setState({ limit: 10 }) let data = { page: 1, limit: 10, - status: this.state.status, - key_word: this.state.key_word + status: this.state.status + } + if (this.state.searchOption) { + data[this.state.searchOption.key] = this.state.key_word } this.getPlanList(data) } @@ -668,10 +703,9 @@ export default class acclist extends React.Component { data[prop] = null this.setState(data) this.setState({ page: 1, limit: 10 }) - let params = { - page: 1, - limit: 10, - key_word: this.state.key_word + let params = { page: 1, limit: 10 } + if (this.state.searchOption) { + params[this.state.searchOption.key] = this.state.key_word } this.getPlanList(params) } @@ -817,26 +851,40 @@ export default class acclist extends React.Component { - {/* */} - this.setState({ key_word: e })} - value={this.state.key_word} - wordSearch={this.iptsureFn.bind(this)} - icon="search" - placeholder={"请输入营销计划名称、分销商名称查询"} - countShow={false} - height={"36px"} - width={"260px"} - onClearItem={(e) => { - this.setState({ key_word: "" }) - let data = { - page: 1, - limit: 10 +
+