add.vue 30 KB

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