add.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <div id="addPlanList">
  3. <el-card style="position: relative;">
  4. <span>基本信息</span>
  5. <el-form :model="basicForm" :rules="basicRules" ref="basic" label-width="auto">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="计划编码">
  9. <el-input
  10. v-model="basicForm.planCode"
  11. size="mini"
  12. disabled
  13. style="width: 200px"
  14. />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="1.5">
  18. <el-form-item label="计划名称" prop="planName">
  19. <el-input
  20. v-model.trim="basicForm.planName"
  21. size="mini"
  22. disabled
  23. clearable
  24. style="width: 200px"
  25. />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-form-item label="线路类型" prop="type" :rules="{ required: true, message: '请选择线路类型', trigger: 'blur' }">
  30. <el-select clearable size="mini" :disabled="sonDisable" v-model="basicForm.type" style="width: 200px">
  31. <el-option v-for="dict in dict.type.mk_plan_route_type" :key="dict.value" :label="dict.label" :value="dict.value">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-form-item label="执行人" prop="chargerName" :rules="{ required: true, message: '请选择执行人', trigger: 'blur' }">
  38. <el-select clearable size="mini" v-model="basicForm.chargerName" :disabled="sonDisable" @focus="choose('CONTACTS_PARAM', true, '请选择执行人')" @clear="clearHang({}, '请选择执行人')" style="width: 200px">
  39. <el-option v-for="item in personOptions" :key="item.id" :label="item.name" :value="item.code"/>
  40. </el-select>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-form-item label="确认状态" prop="state">
  45. <el-select disabled size="mini" v-model="basicForm.state" style="width: 200px">
  46. <el-option v-for="dict in dict.type.mk_plan_state" :key="dict.value" :label="dict.label" :value="dict.value">
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. </el-row>
  52. <el-row :gutter="10">
  53. <el-col :span="1.5">
  54. <el-form-item label="开始时间" prop="startDate" :rules="{ required: true, message: '请选择开始时间', trigger: 'blur' }">
  55. <el-date-picker
  56. v-model="basicForm.startDate"
  57. :disabled="sonDisable"
  58. clearable
  59. type="date"
  60. value-format="yyyy-MM-dd"
  61. :picker-options="pickerOptionsStart"
  62. size="mini"
  63. style="width: 200px"
  64. placeholder="选择开始时间"
  65. >
  66. </el-date-picker>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-form-item label="截止时间" prop="deadlineTime" :rules="{ required: true, message: '请选择截止时间', trigger: 'blur' }">
  71. <el-date-picker
  72. v-model="basicForm.deadlineTime"
  73. :disabled="sonDisable"
  74. clearable
  75. type="date"
  76. value-format="yyyy-MM-dd"
  77. :picker-options="pickerOptionsEnd"
  78. size="mini"
  79. style="width: 200px"
  80. placeholder="选择截止时间"
  81. >
  82. </el-date-picker>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-form-item label="销售区域" prop="marketingAreaName" :rules="{ required: true, message: '请选择销售区域', trigger: 'blur' }">
  87. <el-select clearable v-model="basicForm.marketingAreaName" size="mini" :disabled="sonDisable" @focus="choose('MK_SALESAREA_PARAM', true, '请选择销售区域')" style="width: 200px">
  88. <el-option
  89. v-for="item in deptOptions"
  90. :key="item.id"
  91. :label="item.name"
  92. :value="item.code">
  93. </el-option>
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-form-item label="部门" prop="deptName">
  99. <el-select clearable v-model="basicForm.deptName" size="mini" :disabled="sonDisable" @focus="choose('DEPT_PARAM', true, '部门')" style="width: 200px">
  100. <el-option
  101. v-for="item in deptOptions" :key="item.id" :label="item.name" :value="item.code">
  102. </el-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <div class="btn_grooup">
  108. <span>明细信息</span>
  109. <div>
  110. <el-button type="primary" size="mini" @click="addLine" v-if="!sonDisable">增行</el-button>
  111. <el-button type="primary" size="mini" @click="copy" v-if="sonPageStu == 'check'">复制</el-button>
  112. <el-button type="primary" size="mini" @click="delItems" v-if="sonPageStu == 'edit'">批量删除</el-button>
  113. <el-button type="primary" size="mini" @click="edit" v-if="sonPageStu == 'check' && basicForm.state == '0'">编辑</el-button>
  114. </div>
  115. </div>
  116. <el-table
  117. :data="basicForm.mkBoPlanItemList"
  118. fit
  119. max-height="600"
  120. style="font-size: 12px;"
  121. @selection-change="handleSelectionChange"
  122. >
  123. <el-table-column type="selection" align="center"/>
  124. <el-table-column label="序号" type="index" align="center"/>
  125. <el-table-column show-overflow-tooltip label="计划编号" prop="planCode" width="150"/>
  126. <el-table-column show-overflow-tooltip label="日期" prop="date" width="230px" :render-header="addRedStar">
  127. <template slot-scope="scope">
  128. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'date'" :rules="{ required: true, message: '请填写日期', trigger: 'blur' }">
  129. <el-date-picker
  130. v-model="scope.row.date"
  131. :readonly="sonDisable"
  132. clearable
  133. type="date"
  134. size="mini"
  135. value-format="yyyy-MM-dd"
  136. :picker-options="pickerOptions"
  137. placeholder="选择日期"
  138. >
  139. </el-date-picker>
  140. </el-form-item>
  141. </template>
  142. </el-table-column>
  143. <el-table-column show-overflow-tooltip label="客户" prop="customerName" min-width="230" :render-header="addRedStar">
  144. <template slot-scope="scope">
  145. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'customerName'" :rules="{ required: true, message: '请选择客户', trigger: 'blur' }">
  146. <el-select clearable size="mini" v-model="scope.row.customerName" :disabled="sonDisable" @focus="chooseSon(scope.$index, 'CUSTOMER_PARAM_ZT', true, '请选择客户', {charger: basicForm.charger})" @clear="clearHang(scope.$index, '请选择客户')" style="width: 200px">
  147. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.code" />
  148. </el-select>
  149. </el-form-item>
  150. </template>
  151. </el-table-column>
  152. <el-table-column show-overflow-tooltip label="联系人" prop="contactName" min-width="230" :render-header="addRedStar">
  153. <template slot-scope="scope">
  154. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'contactName'" :rules="{ required: true, message: '请选择联系人', trigger: 'blur' }">
  155. <el-select clearable size="mini" v-model="scope.row.contactName" :disabled="sonDisable" @focus="chooseSon(scope.$index, 'LINKMAN_PARAM', true, '请选择联系人', {customer: scope.row.customer, charger: basicForm.charger})" style="width: 200px">
  156. <el-option v-for="item in linkOptions" :key="item.id" :label="item.name" :value="item.code" />
  157. </el-select>
  158. </el-form-item>
  159. </template>
  160. </el-table-column>
  161. <el-table-column show-overflow-tooltip label="详细地址" prop="address" min-width="200">
  162. <template slot-scope="scope">
  163. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'address'">
  164. <el-input clearable :readonly="sonDisable" size="mini" v-model="scope.row.address"/>
  165. </el-form-item>
  166. </template>
  167. </el-table-column>
  168. <el-table-column show-overflow-tooltip label="拜访目的" prop="purpose" min-width="200" :render-header="addRedStar">
  169. <template slot-scope="scope">
  170. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'purpose'" :rules="{ required: true, message: '请选择拜访目的', trigger: 'blur' }">
  171. <el-select clearable :disabled="sonDisable" v-model="scope.row.purpose" size="mini">
  172. <el-option v-for=" dict in dict.type.mk_bo_behavior_goal" :key="dict.value" :label="dict.label" :value="dict.value">
  173. </el-option>
  174. </el-select>
  175. </el-form-item>
  176. </template>
  177. </el-table-column>
  178. <el-table-column show-overflow-tooltip label="商机" prop="boName" min-width="330">
  179. <template slot-scope="scope">
  180. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'boName'">
  181. <el-select clearable size="mini" v-model="scope.row.boName" :disabled="sonDisable" @focus="chooseSon(scope.$index, 'BO_PARAM', true, '请选择商机', {charger: basicForm.charger, customer: scope.row.customer})" @clear="clearHang(scope.$index, '请选择商机')" style="width: 300px">
  182. <el-option v-for="item in boOptions" :key="item.id" :label="item.name" :value="item.code" />
  183. </el-select>
  184. </el-form-item>
  185. </template>
  186. </el-table-column>
  187. <el-table-column :readonly="sonDisable" show-overflow-tooltip label="营销活动" prop="marketingCampaign" min-width="200">
  188. <template slot-scope="scope">
  189. <el-form-item class="hang" :prop="'mkBoPlanItemList.' + scope.$index + '.' + 'marketingCampaign'">
  190. <el-input clearable :readonly="sonDisable" size="mini" v-model="scope.row.marketingCampaign"/>
  191. </el-form-item>
  192. </template>
  193. </el-table-column>
  194. <el-table-column
  195. fixed="right"
  196. label="操作"
  197. align="center"
  198. >
  199. <template slot-scope="scope">
  200. <el-button type="text" size="mini" :disabled="sonDisable" @click="delLine(scope.$index, scope.row)">删除</el-button>
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. </el-form>
  205. </el-card>
  206. <div class="btn_group">
  207. <el-col :span="1.5">
  208. <el-button type="primary" size="mini" plain @click="save" v-if="sonPageStu == 'add' || sonPageStu == 'edit'">保存</el-button>
  209. </el-col>
  210. <el-col :span="1.5" style="margin: 0 10px;">
  211. <el-button size="mini" plain @click="back">返回</el-button>
  212. </el-col>
  213. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  214. </div>
  215. </div>
  216. </template>
  217. <script>
  218. import {addPlan, getPlanDetail, editPlan, delPlanItem} from '@/api/business/spd/task_management/visitingPlan/visitingPlan.js'
  219. import Refers from '@/components/Refers/refers.vue'
  220. // 用于回显参照框数据
  221. import {getRefer} from '@/api/purchase/basic.js'
  222. export default {
  223. name: 'addPlanList',
  224. props: ['pageStu', 'row', 'disable'],
  225. dicts: ['mk_plan_state', 'mk_plan_route_type', 'mk_bo_behavior_goal'],
  226. components: {
  227. Refers
  228. },
  229. model: {
  230. prop: 'isList',
  231. event: 'jugislist'
  232. },
  233. data() {
  234. return {
  235. // 不能直接改变props传来的值
  236. sonPageStu: this.pageStu,
  237. sonDisable: this.disable,
  238. // dialog: {
  239. // config: false
  240. // },
  241. basicForm: {
  242. id: '',
  243. planCode: '',
  244. planName : '',
  245. charger: this.$store.state.user.id,
  246. chargerName: this.$store.state.user.nickName,
  247. dept: this.$store.state.user.deptId,
  248. deptName: this.$store.state.user.deptName,
  249. startDate: this.getNextWeek(1),
  250. deadlineTime: this.getNextWeek(7),
  251. type: '0',
  252. state: '0',
  253. marketingArea: '',
  254. marketingAreaName: '',
  255. mkBoPlanItemList: []
  256. },
  257. delPlanItemList: [],
  258. basicRules: {},
  259. tableList: [],
  260. referCondition: {
  261. type: '',
  262. isPage: true,
  263. title: ''
  264. },
  265. tableIndex: null,
  266. ids: [],
  267. boOptions: [],
  268. linkOptions: [],
  269. manOptions: [],
  270. personOptions: [],
  271. deptOptions: [],
  272. customerOptions: [],
  273. salesAreaOptions: [],
  274. //定义主表开始时间的范围不能早于今天
  275. pickerOptionsStart: {
  276. disabledDate: (time) => {
  277. return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000 || time.getTime() > (new Date(this.basicForm.deadlineTime)).getTime()
  278. }
  279. },
  280. //定义主表截止时间的范围不能早于开始时间
  281. pickerOptionsEnd: {
  282. disabledDate: (time) => {
  283. return time.getTime() < (new Date(this.basicForm.startDate)).getTime()
  284. }
  285. },
  286. //定义子表日期的范围不能早于开始时间且不能晚于截止时间
  287. pickerOptions: {
  288. disabledDate: (time) => {
  289. return time.getTime() < (new Date(this.basicForm.startDate)).getTime() || time.getTime() > (new Date(this.basicForm.deadlineTime)).getTime()
  290. }
  291. },
  292. //判断默认明细行带出完毕后,增行日期等于当前日期的标识
  293. isFlag: false
  294. }
  295. },
  296. updated() {},
  297. mounted() {},
  298. created() {
  299. //查看系统数据
  300. console.log(this.$store.state.user, 'this.$store.state.user')
  301. if(this.pageStu == 'check') {
  302. console.log('数据', this.row)
  303. this.getDetails(this.row)
  304. } else if (this.pageStu == 'edit') {
  305. this.getDetails(this.row)
  306. } else if (this.pageStu == 'add') {
  307. //新增时默认带出7条明细行
  308. this.defaultDetailLine(7)
  309. }
  310. },
  311. methods:{
  312. copy() {
  313. this.isFlag = true;
  314. this.$modal.notifySuccess("复制成功");
  315. this.sonPageStu = 'add'
  316. this.sonDisable = false
  317. // this.getDetails(this.row)
  318. this.basicForm.id = ''
  319. this.basicForm.planCode = ''
  320. this.basicForm.state = 0
  321. //复制之后执行人和部门变为当前账号所有者
  322. this.basicForm.charger = this.$store.state.user.id,
  323. this.basicForm.chargerName = this.$store.state.user.nickName
  324. this.basicForm.dept = this.$store.state.user.deptId
  325. this.basicForm.deptName = this.$store.state.user.deptName
  326. if (this.basicForm.chargerName) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.chargerName) }
  327. if (this.basicForm.marketingAreaName) { this.reBackRefer('MK_SALESAREA_PARAM', this.basicForm.marketingAreaName) }
  328. if (this.basicForm.deptName) { this.reBackRefer('DEPT_PARAM', this.basicForm.deptName) }
  329. this.basicForm.mkBoPlanItemList.forEach(item => {
  330. item.planCode = ''
  331. })
  332. },
  333. handleData() {
  334. console.log('222')
  335. // 复制新增把id,编码,创建人置为空,子表去掉id
  336. this.basicForm.id = ''
  337. this.basicForm.planCode = ''
  338. if (this.basicForm.mkBoPlanItemList.length !== 0) {
  339. this.basicForm.mkBoPlanItemList.forEach(item => {
  340. if (item.id) {
  341. delete item.id
  342. }
  343. if (item.planId) {
  344. delete item.planId
  345. }
  346. })
  347. }
  348. },
  349. // 如果需要回显则调用详情接口
  350. getDetails(row) {
  351. getPlanDetail(row.id).then(res => {
  352. if (res.code === 200) {
  353. // console.log('res', res)
  354. this.basicForm = res.data
  355. }
  356. })
  357. },
  358. async save() {
  359. if(this.basicForm.mkBoPlanItemList.length !== 0) {
  360. this.$refs['basic'].validate((valid, obj) => {
  361. if(valid) {
  362. this.$modal.loading("保存中...");
  363. if(this.sonPageStu == 'add') {
  364. this.planNameAssignment();
  365. this.handleData()
  366. addPlan(this.basicForm).then(res => {
  367. console.log(333)
  368. if (res.code === 200) {
  369. this.$modal.notifySuccess("保存成功");
  370. this.$modal.closeLoading();
  371. this.back()
  372. }
  373. }).catch(err => {
  374. this.$modal.closeLoading();
  375. })
  376. } else if (this.sonPageStu == 'edit') {
  377. this.planNameAssignment();
  378. let list = []
  379. list.push(...this.basicForm.mkBoPlanItemList, ...this.delPlanItemList)
  380. // 深拷贝一下参数对象
  381. let param = JSON.parse(JSON.stringify(this.basicForm))
  382. console.log('深拷贝对象',param);
  383. param.mkBoPlanItemList = list
  384. // this.basicForm.mkBoPlanItemList.push(...this.delPlanItemList)
  385. editPlan(param).then(res => {
  386. if (res.code === 200) {
  387. this.$modal.notifySuccess("编辑成功");
  388. this.$modal.closeLoading();
  389. this.back()
  390. }
  391. }).catch(err => {
  392. this.$modal.closeLoading();
  393. })
  394. }
  395. } else {
  396. // 校验加弹窗
  397. const jiaoyan = []
  398. for(let key in obj) {
  399. jiaoyan.push(obj[key][0].message);
  400. }
  401. this.$modal.notifyWarning(jiaoyan[0]);
  402. return false
  403. }
  404. })
  405. } else {
  406. this.$modal.msgWarning("明细信息不能为空!");
  407. }
  408. },
  409. //拜访计划名称赋值
  410. planNameAssignment() {
  411. this.basicForm.planName = this.basicForm.chargerName + '-' + '周计划拜访' + '(' + this.basicForm.startDate.substr(5) + '至' + this.basicForm.deadlineTime.substr(5) + ')'
  412. },
  413. // 增行
  414. addLine(date) {
  415. if ((this.sonPageStu == 'edit') || (this.isFlag && this.sonPageStu == 'add')) {
  416. date = this.basicForm.startDate;
  417. }
  418. const newLine = {
  419. id: null,
  420. planId: this.basicForm.id,
  421. planCode: this.basicForm.planCode,
  422. date: date,
  423. customer: null,
  424. customerName: null,
  425. contact: null,
  426. contactName: null,
  427. address: null,
  428. purpose: null,
  429. bo: null,
  430. boName: null,
  431. marketingCampaign: null,
  432. delFlag: 0,
  433. // 新增字段
  434. model: null,
  435. }
  436. this.basicForm.mkBoPlanItemList.push(newLine)
  437. },
  438. // 批量删除按钮
  439. delItems() {
  440. if(this.ids.length == 0) {
  441. this.$modal.msgWarning("请选中至少一条数据");
  442. } else {
  443. let param = this.ids.join()
  444. this.$modal.confirm('确认信息').then(() => {
  445. delPlanItem(param).then(res => {
  446. if (res.code === 200) {
  447. this.$modal.notifySuccess("删除成功");
  448. this.getDetails(this.row)
  449. }
  450. })
  451. }).catch(() => {})
  452. }
  453. },
  454. delLine(index, row) {
  455. console.log('删除行:', index)
  456. console.log('改变行:', row)
  457. row.delFlag = '2'
  458. let delList = []
  459. delList = this.basicForm.mkBoPlanItemList.filter(item => {
  460. return item.delFlag == '2'
  461. })
  462. this.basicForm.mkBoPlanItemList = this.basicForm.mkBoPlanItemList.filter(item => {
  463. return item.delFlag == '0'
  464. })
  465. this.delPlanItemList.push(...delList)
  466. console.log('删除的数组',this.delPlanItemList)
  467. },
  468. edit() {
  469. this.isFlag = true;
  470. this.sonPageStu = 'edit'
  471. this.sonDisable = false
  472. this.basicForm.mkBoPlanItemList.forEach(item => {
  473. item.planCode = this.basicForm.planCode
  474. })
  475. console.log(this.basicForm.startDate)
  476. },
  477. back() {
  478. this.$emit('jugislist', true)
  479. // let queryParams = {
  480. // pageNum: 1,
  481. // pageSize: 10
  482. // }
  483. this.$emit('refresh')
  484. },
  485. // 如果需要回显则调用详情接口
  486. getDetails(row) {
  487. getPlanDetail(row.id).then(res => {
  488. if (res.code === 200) {
  489. this.basicForm = res.data
  490. for (let i = 0; i < this.basicForm.mkBoPlanItemList.length; i++) {
  491. this.basicForm.mkBoPlanItemList[i].planCode = res.data.planCode
  492. }
  493. }
  494. })
  495. },
  496. handleSelectionChange(selection) {
  497. console.log('选中', selection)
  498. this.ids = selection.map(item => item.id)
  499. console.log('选中数组', this.ids.join())
  500. },
  501. // 回显参照框
  502. reBackRefer(type, id, title) {
  503. getRefer({type: type, id: id}).then(res => {
  504. if (type == 'CONTACTS_PARAM') {
  505. this.personOptions = res.rows
  506. }
  507. if(type == 'MK_SALESAREA_PARAM') {
  508. this.salesAreaOptions = res.rows
  509. }
  510. if (type == 'DEPT_PARAM') {
  511. this.deptOptions = res.rows
  512. }
  513. if (type == 'CUSTOMER_PARAM_ZT') {
  514. this.customerOptions = res.rows
  515. }
  516. if (type == 'LINKMAN_PARAM') {
  517. this.linkOptions = res.rows
  518. }
  519. if(type == 'BO_PARAM') {
  520. this.boOptions = res.rows
  521. }
  522. })
  523. },
  524. //公共基本信息选择参照带出数据
  525. choose(type, isPage, title) {
  526. this.referCondition.type = type
  527. this.referCondition.isPage = isPage
  528. this.referCondition.title = title
  529. this.$refs.refer.init(this.referCondition)
  530. },
  531. //公共明细行选择参照带出数据
  532. chooseSon(index, type, isPage, title, parame) {
  533. this.tableIndex = index
  534. this.referCondition.type = type
  535. this.referCondition.isPage = isPage
  536. this.referCondition.title = title
  537. if (title == "请选择客户") {
  538. if(parame.charger) {
  539. this.referCondition.parame = parame
  540. this.$refs.refer.init(this.referCondition)
  541. } else {
  542. this.$modal.notifyWarning("请先确认执行人");
  543. }
  544. } else if (title == "请选择联系人") {
  545. if(parame.customer) {
  546. this.referCondition.parame = parame
  547. this.$refs.refer.init(this.referCondition)
  548. } else {
  549. this.$modal.notifyWarning("请先确认客户");
  550. }
  551. } else if (title == "请选择商机") {
  552. if(parame.customer) {
  553. this.referCondition.parame = parame
  554. this.$refs.refer.init(this.referCondition)
  555. } else {
  556. this.$modal.notifyWarning("请先确认客户");
  557. }
  558. }
  559. },
  560. //联动清除明细行里其它的字段
  561. clearHang(index, title) {
  562. if (title == '请选择执行人') {
  563. this.basicForm.dept = null
  564. this.basicForm.deptName = null
  565. this.basicForm.mkBoPlanItemList.forEach(item => {
  566. item.customer = null
  567. item.customerName = null
  568. item.contact = null
  569. item.contactName = null
  570. item.bo = null
  571. item.boName = null
  572. })
  573. }
  574. // if (title == '请选择开始时间' || title == '请选择截止时间') {
  575. // this.basicForm.mkBoPlanItemList.forEach(item => {
  576. // item.date = null
  577. // })
  578. // }
  579. if (title == '请选择客户') {
  580. this.basicForm.mkBoPlanItemList[index].contact = null
  581. this.basicForm.mkBoPlanItemList[index].contactName = null
  582. this.basicForm.mkBoPlanItemList[index].bo = null
  583. this.basicForm.mkBoPlanItemList[index].boName = null
  584. }
  585. if (title == '请选择商机') {
  586. this.basicForm.mkBoPlanItemList[index].customer = null
  587. this.basicForm.mkBoPlanItemList[index].customerName = null
  588. this.basicForm.mkBoPlanItemList[index].bo = null
  589. this.basicForm.mkBoPlanItemList[index].boName = null
  590. }
  591. },
  592. selectionsToInput(selection) {
  593. //执行人参照
  594. if(this.referCondition.type == 'CONTACTS_PARAM') {
  595. this.personOptions = selection
  596. this.basicForm.charger = selection[0].id
  597. this.basicForm.chargerName = selection[0].name
  598. this.basicForm.dept = selection[0].deptId
  599. this.basicForm.deptName = selection[0].deptName
  600. }
  601. //销售区域参照
  602. if(this.referCondition.type == 'MK_SALESAREA_PARAM') {
  603. this.salesAreaOptions = selection
  604. this.basicForm.marketingArea = selection[0].id
  605. this.basicForm.marketingAreaName = selection[0].name
  606. }
  607. //部门参照
  608. if(this.referCondition.type == 'DEPT_PARAM') {
  609. this.deptOptions = selection
  610. this.basicForm.dept = selection[0].id
  611. this.basicForm.deptName = selection[0].name
  612. }
  613. //客户参照
  614. if(this.referCondition.type == 'CUSTOMER_PARAM_ZT') {
  615. this.customerOptions = selection
  616. this.basicForm.mkBoPlanItemList[this.tableIndex].customer = selection[0].id
  617. this.basicForm.mkBoPlanItemList[this.tableIndex].customerName = selection[0].name
  618. }
  619. //联系人参照
  620. if(this.referCondition.type == 'LINKMAN_PARAM') {
  621. this.linkOptions = selection
  622. this.basicForm.mkBoPlanItemList[this.tableIndex].contact = selection[0].id
  623. this.basicForm.mkBoPlanItemList[this.tableIndex].contactName = selection[0].name
  624. }
  625. //商机参照
  626. if(this.referCondition.type == 'BO_PARAM') {
  627. this.boOptions = selection
  628. this.basicForm.mkBoPlanItemList[this.tableIndex].bo = selection[0].id
  629. this.basicForm.mkBoPlanItemList[this.tableIndex].boName = selection[0].name
  630. this.basicForm.mkBoPlanItemList[this.tableIndex].customer = selection[0].customer
  631. this.basicForm.mkBoPlanItemList[this.tableIndex].customerName = selection[0].customerName
  632. }
  633. },
  634. //获取当前时间
  635. getCurrentTime() {
  636. let date = new Date();
  637. return date;
  638. },
  639. //获取下周七天日期,day表示想要星期几
  640. getNextWeek(day) {
  641. const week = [];
  642. for (let i = 0; i < 7; i++) {
  643. let Stamp = new Date();
  644. let num = 7 - Stamp.getDay() + 1 + i;
  645. Stamp.setDate(Stamp.getDate() + num);
  646. week[i] = Stamp.getFullYear() + '-' + (Stamp.getMonth() + 1) + '-' + Stamp.getDate();
  647. }
  648. return week[day - 1];
  649. },
  650. //新增时默认带出num条明细行
  651. defaultDetailLine(num) {
  652. for (let i = 0; i < num; i++) {
  653. this.addLine(this.getNextWeek(i + 1));
  654. }
  655. this.isFlag = true;
  656. },
  657. //必选标识
  658. addRedStar(h, { column }) {
  659. return [
  660. h('span', { style: 'color: #F56C6C' }, '*'),
  661. h('span', ' ' + column.label)
  662. ];
  663. },
  664. }
  665. }
  666. </script>
  667. <style lang="scss" scoped>
  668. .btn_group {
  669. width: 100%;
  670. margin: 20px 0;
  671. display: flex;
  672. justify-content: center;
  673. }
  674. .btn_grooup {
  675. margin-bottom: 10px;
  676. display: flex;
  677. justify-content: space-between;
  678. }
  679. .hang {
  680. margin: auto;
  681. }
  682. .hang ::v-deep .el-form-item__content{
  683. margin-left: 0px !important;
  684. }
  685. </style>