add.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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 00:00:00"
  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 00:00:00"
  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 00:00:00"
  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})" 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. this.basicForm.startDate = this.basicForm.startDate + ' 00:00:00'
  310. this.basicForm.deadlineTime = this.basicForm.deadlineTime + ' 00:00:00'
  311. this.basicForm.mkBoPlanItemList.forEach(item => {
  312. item.date = item.date + ' 00:00:00'
  313. })
  314. }
  315. },
  316. methods:{
  317. copy() {
  318. this.isFlag = true;
  319. this.$modal.notifySuccess("复制成功");
  320. this.sonPageStu = 'add'
  321. this.sonDisable = false
  322. // this.getDetails(this.row)
  323. this.basicForm.id = ''
  324. this.basicForm.planCode = ''
  325. this.basicForm.createBy = null
  326. this.basicForm.createByName = null
  327. this.basicForm.state = 0
  328. //复制之后执行人和部门变为当前账号所有者
  329. this.basicForm.charger = this.$store.state.user.id,
  330. this.basicForm.chargerName = this.$store.state.user.nickName
  331. this.basicForm.dept = this.$store.state.user.deptId
  332. this.basicForm.deptName = this.$store.state.user.deptName
  333. if (this.basicForm.chargerName) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.chargerName) }
  334. if (this.basicForm.marketingAreaName) { this.reBackRefer('MK_SALESAREA_PARAM', this.basicForm.marketingAreaName) }
  335. if (this.basicForm.deptName) { this.reBackRefer('DEPT_PARAM', this.basicForm.deptName) }
  336. this.basicForm.mkBoPlanItemList.forEach(item => {
  337. item.planCode = ''
  338. })
  339. },
  340. handleData() {
  341. console.log('222')
  342. // 复制新增把id,编码,创建人置为空,子表去掉id
  343. this.basicForm.id = ''
  344. this.basicForm.planCode = ''
  345. if (this.basicForm.mkBoPlanItemList.length !== 0) {
  346. this.basicForm.mkBoPlanItemList.forEach(item => {
  347. if (item.id) {
  348. delete item.id
  349. }
  350. if (item.planId) {
  351. delete item.planId
  352. }
  353. })
  354. }
  355. },
  356. // 如果需要回显则调用详情接口
  357. getDetails(row) {
  358. getPlanDetail(row.id).then(res => {
  359. if (res.code === 200) {
  360. // console.log('res', res)
  361. this.basicForm = res.data
  362. this.basicForm.startDate = this.basicForm.startDate + ' 00:00:00'
  363. this.basicForm.deadlineTime = this.basicForm.deadlineTime + ' 00:00:00'
  364. this.basicForm.mkBoPlanItemList.forEach(item => {
  365. item.date = item.date + ' 00:00:00'
  366. })
  367. }
  368. }).then(() => {
  369. this.loading = false
  370. }).catch(err => {
  371. this.loading = false
  372. })
  373. },
  374. async save() {
  375. if(this.basicForm.mkBoPlanItemList.length !== 0) {
  376. this.$refs['basic'].validate((valid, obj) => {
  377. if(valid) {
  378. this.$modal.loading("保存中...");
  379. if(this.sonPageStu == 'add') {
  380. this.planNameAssignment();
  381. this.handleData()
  382. addPlan(this.basicForm).then(res => {
  383. console.log(333)
  384. if (res.code === 200) {
  385. this.$modal.notifySuccess("保存成功");
  386. this.$modal.closeLoading();
  387. this.back()
  388. }
  389. }).catch(err => {
  390. this.$modal.closeLoading();
  391. })
  392. } else if (this.sonPageStu == 'edit') {
  393. this.planNameAssignment();
  394. let list = []
  395. list.push(...this.basicForm.mkBoPlanItemList, ...this.delPlanItemList)
  396. // 深拷贝一下参数对象
  397. let param = JSON.parse(JSON.stringify(this.basicForm))
  398. console.log('深拷贝对象',param);
  399. param.mkBoPlanItemList = list
  400. // this.basicForm.mkBoPlanItemList.push(...this.delPlanItemList)
  401. editPlan(param).then(res => {
  402. if (res.code === 200) {
  403. this.$modal.notifySuccess("编辑成功");
  404. this.$modal.closeLoading();
  405. this.back()
  406. }
  407. }).catch(err => {
  408. this.$modal.closeLoading();
  409. })
  410. }
  411. } else {
  412. // 校验加弹窗
  413. const jiaoyan = []
  414. for(let key in obj) {
  415. jiaoyan.push(obj[key][0].message);
  416. }
  417. this.$modal.notifyWarning(jiaoyan[0]);
  418. return false
  419. }
  420. })
  421. } else {
  422. this.$modal.msgWarning("明细信息不能为空!");
  423. }
  424. },
  425. //拜访计划名称赋值
  426. planNameAssignment() {
  427. console.log(this.basicForm.startDate.substr(5, 5))
  428. this.basicForm.planName = this.basicForm.chargerName + '-' + '周计划拜访' + '(' + this.basicForm.startDate.substr(5, 5) + '至' + this.basicForm.deadlineTime.substr(5, 5) + ')'
  429. },
  430. // 增行
  431. addLine(date) {
  432. if ((this.sonPageStu == 'edit') || (this.isFlag && this.sonPageStu == 'add')) {
  433. date = this.basicForm.startDate;
  434. }
  435. const newLine = {
  436. id: null,
  437. planId: this.basicForm.id,
  438. planCode: this.basicForm.planCode,
  439. date: date,
  440. customer: null,
  441. customerName: null,
  442. contact: null,
  443. contactName: null,
  444. address: null,
  445. purpose: null,
  446. bo: null,
  447. boName: null,
  448. marketingCampaign: null,
  449. delFlag: 0,
  450. // 新增字段
  451. model: null,
  452. }
  453. this.basicForm.mkBoPlanItemList.push(newLine)
  454. },
  455. // 批量删除按钮
  456. delItems() {
  457. if(this.ids.length == 0) {
  458. this.$modal.msgWarning("请选中至少一条数据");
  459. } else {
  460. let param = this.ids.join()
  461. this.$modal.confirm('确认信息').then(() => {
  462. delPlanItem(param).then(res => {
  463. if (res.code === 200) {
  464. this.$modal.notifySuccess("删除成功");
  465. this.getDetails(this.row)
  466. }
  467. })
  468. }).catch(() => {})
  469. }
  470. },
  471. delLine(index, row) {
  472. console.log('删除行:', index)
  473. console.log('改变行:', row)
  474. row.delFlag = '2'
  475. let delList = []
  476. delList = this.basicForm.mkBoPlanItemList.filter(item => {
  477. return item.delFlag == '2'
  478. })
  479. this.basicForm.mkBoPlanItemList = this.basicForm.mkBoPlanItemList.filter(item => {
  480. return item.delFlag == '0'
  481. })
  482. this.delPlanItemList.push(...delList)
  483. console.log('删除的数组',this.delPlanItemList)
  484. },
  485. edit() {
  486. this.getDetails(this.row)
  487. this.isFlag = true;
  488. this.sonPageStu = 'edit'
  489. this.sonDisable = false
  490. //调整日期格式
  491. this.basicForm.startDate = this.basicForm.startDate + ' 00:00:00'
  492. this.basicForm.deadlineTime = this.basicForm.deadlineTime + ' 00:00:00'
  493. this.basicForm.mkBoPlanItemList.forEach(item => {
  494. item.planCode = this.basicForm.planCode
  495. item.date = item.date + ' 00:00:00'
  496. })
  497. },
  498. back() {
  499. this.$emit('jugislist', true)
  500. // let queryParams = {
  501. // pageNum: 1,
  502. // pageSize: 10
  503. // }
  504. this.$emit('refresh')
  505. },
  506. handleSelectionChange(selection) {
  507. console.log('选中', selection)
  508. this.ids = selection.map(item => item.id)
  509. console.log('选中数组', this.ids.join())
  510. },
  511. // 回显参照框
  512. reBackRefer(type, id, title) {
  513. getRefer({type: type, id: id}).then(res => {
  514. if (type == 'CONTACTS_PARAM') {
  515. this.personOptions = res.rows
  516. }
  517. if(type == 'MK_SALESAREA_PARAM') {
  518. this.salesAreaOptions = res.rows
  519. }
  520. if (type == 'DEPT_PARAM') {
  521. this.deptOptions = res.rows
  522. }
  523. if (type == 'CUSTOMER_PARAM_ZT') {
  524. this.customerOptions = res.rows
  525. }
  526. if (type == 'LINKMAN_PARAM') {
  527. this.linkOptions = res.rows
  528. }
  529. if(type == 'BO_PARAM') {
  530. this.boOptions = res.rows
  531. }
  532. })
  533. },
  534. //公共基本信息选择参照带出数据
  535. choose(type, isPage, title) {
  536. this.referCondition.type = type
  537. this.referCondition.isPage = isPage
  538. this.referCondition.title = title
  539. this.$refs.refer.init(this.referCondition)
  540. },
  541. //公共明细行选择参照带出数据
  542. chooseSon(index, type, isPage, title, parame) {
  543. this.tableIndex = index
  544. this.referCondition.type = type
  545. this.referCondition.isPage = isPage
  546. this.referCondition.title = title
  547. if (title == "请选择客户") {
  548. if(parame.charger) {
  549. this.referCondition.parame = parame
  550. this.$refs.refer.init(this.referCondition)
  551. } else {
  552. this.$modal.notifyWarning("请先确认执行人");
  553. }
  554. } else if (title == "请选择联系人") {
  555. if(parame.customer) {
  556. this.referCondition.parame = parame
  557. this.$refs.refer.init(this.referCondition)
  558. } else {
  559. this.$modal.notifyWarning("请先确认客户");
  560. }
  561. } else if (title == "请选择商机") {
  562. if(parame.customer) {
  563. this.referCondition.parame = parame
  564. this.$refs.refer.init(this.referCondition)
  565. } else {
  566. this.$modal.notifyWarning("请先确认客户");
  567. }
  568. }
  569. },
  570. //联动清除明细行里其它的字段
  571. clearHang(index, title) {
  572. if (title == '请选择执行人') {
  573. this.basicForm.dept = null
  574. this.basicForm.deptName = null
  575. this.basicForm.mkBoPlanItemList.forEach(item => {
  576. item.customer = null
  577. item.customerName = null
  578. item.contact = null
  579. item.contactName = null
  580. item.bo = null
  581. item.boName = null
  582. })
  583. }
  584. // if (title == '请选择开始时间' || title == '请选择截止时间') {
  585. // this.basicForm.mkBoPlanItemList.forEach(item => {
  586. // item.date = null
  587. // })
  588. // }
  589. if (title == '请选择客户') {
  590. this.basicForm.mkBoPlanItemList[index].contact = null
  591. this.basicForm.mkBoPlanItemList[index].contactName = null
  592. this.basicForm.mkBoPlanItemList[index].bo = null
  593. this.basicForm.mkBoPlanItemList[index].boName = null
  594. }
  595. if (title == '请选择商机') {
  596. this.basicForm.mkBoPlanItemList[index].customer = null
  597. this.basicForm.mkBoPlanItemList[index].customerName = null
  598. this.basicForm.mkBoPlanItemList[index].bo = null
  599. this.basicForm.mkBoPlanItemList[index].boName = null
  600. }
  601. },
  602. selectionsToInput(selection) {
  603. //执行人参照
  604. if(this.referCondition.type == 'CONTACTS_PARAM') {
  605. this.personOptions = selection
  606. this.basicForm.charger = selection[0].id
  607. this.basicForm.chargerName = selection[0].name
  608. this.basicForm.dept = selection[0].deptId
  609. this.basicForm.deptName = selection[0].deptName
  610. }
  611. //销售区域参照
  612. if(this.referCondition.type == 'MK_SALESAREA_PARAM') {
  613. this.salesAreaOptions = selection
  614. this.basicForm.marketingArea = selection[0].id
  615. this.basicForm.marketingAreaName = selection[0].name
  616. }
  617. //部门参照
  618. if(this.referCondition.type == 'DEPT_PARAM') {
  619. this.deptOptions = selection
  620. this.basicForm.dept = selection[0].id
  621. this.basicForm.deptName = selection[0].name
  622. }
  623. //客户参照
  624. if(this.referCondition.type == 'CUSTOMER_PARAM_ZT') {
  625. this.customerOptions = selection
  626. this.basicForm.mkBoPlanItemList[this.tableIndex].customer = selection[0].id
  627. this.basicForm.mkBoPlanItemList[this.tableIndex].customerName = selection[0].name
  628. }
  629. //联系人参照
  630. if(this.referCondition.type == 'LINKMAN_PARAM') {
  631. this.linkOptions = selection
  632. this.basicForm.mkBoPlanItemList[this.tableIndex].contact = selection[0].id
  633. this.basicForm.mkBoPlanItemList[this.tableIndex].contactName = selection[0].name
  634. }
  635. //商机参照
  636. if(this.referCondition.type == 'BO_PARAM') {
  637. this.boOptions = selection
  638. this.basicForm.mkBoPlanItemList[this.tableIndex].bo = selection[0].id
  639. this.basicForm.mkBoPlanItemList[this.tableIndex].boName = selection[0].name
  640. this.basicForm.mkBoPlanItemList[this.tableIndex].customer = selection[0].customer
  641. this.basicForm.mkBoPlanItemList[this.tableIndex].customerName = selection[0].customerName
  642. }
  643. },
  644. //获取当前时间
  645. getCurrentTime() {
  646. let date = new Date();
  647. return date;
  648. },
  649. //获取下周七天日期,day表示想要星期几
  650. getNextWeek(day) {
  651. const week = [];
  652. for (let i = 0; i < 7; i++) {
  653. let Stamp = new Date();
  654. let num = 7 - Stamp.getDay() + 1 + i;
  655. Stamp.setDate(Stamp.getDate() + num);
  656. let Mmonth = Stamp.getMonth() + 1;
  657. let MMmonth = Mmonth < 10 ? '0' + Mmonth : Mmonth;
  658. let ddate = Stamp.getDate();
  659. let dddate = ddate < 10 ? '0' + ddate : ddate;
  660. week[i] = Stamp.getFullYear() + '-' + MMmonth + '-' + dddate;
  661. }
  662. return week[day - 1];
  663. },
  664. //新增时默认带出num条明细行
  665. defaultDetailLine(num) {
  666. for (let i = 0; i < num; i++) {
  667. this.addLine(this.getNextWeek(i + 1));
  668. }
  669. this.isFlag = true;
  670. },
  671. //必选标识
  672. addRedStar(h, { column }) {
  673. return [
  674. h('span', { style: 'color: #F56C6C' }, '*'),
  675. h('span', ' ' + column.label)
  676. ];
  677. },
  678. }
  679. }
  680. </script>
  681. <style lang="scss" scoped>
  682. .btn_group {
  683. width: 100%;
  684. margin: 20px 0;
  685. display: flex;
  686. justify-content: center;
  687. }
  688. .btn_grooup {
  689. margin-bottom: 10px;
  690. display: flex;
  691. justify-content: space-between;
  692. }
  693. .hang {
  694. margin: auto;
  695. }
  696. .hang ::v-deep .el-form-item__content{
  697. margin-left: 0px !important;
  698. }
  699. </style>