targetedPopulation.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440
  1. <style>
  2. #table_time_selected1 tr {
  3. border: 1px solid rgb(102, 162, 243);
  4. }
  5. .plug-timer-grid th {
  6. line-height: 25px;
  7. }
  8. .module-form .ant-form-item-required::before {
  9. display: inline-block;
  10. margin-right: 4px;
  11. color: #f5222d;
  12. font-size: 14px;
  13. font-family: SimSun, sans-serif;
  14. line-height: 1;
  15. content: '';
  16. }
  17. .else-label .ant-form-item-label label::after {
  18. content: '';
  19. position: relative;
  20. top: -0.5px;
  21. margin: 0 8px 0 2px;
  22. }
  23. </style>
  24. <style scoped>
  25. ul {
  26. padding-left: 0;
  27. }
  28. li {
  29. list-style: none;
  30. }
  31. li:hover {
  32. background: #f2f2f2;
  33. }
  34. </style>
  35. <template>
  36. <a-form :form="form" class="module-form" @submit="handleSubmit">
  37. <a-form-item
  38. label="地区"
  39. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  40. :wrapperCol="{ lg: { span: 17 }, sm: { span: 17 } }"
  41. >
  42. <a-radio-group @change="regionChange" v-model="allForm.regionType" buttonStyle="solid">
  43. <a-radio-button value="noLimit">不限</a-radio-button>
  44. <a-radio-button value="limit">指定地区</a-radio-button>
  45. </a-radio-group>
  46. <div v-if="allForm.regionType == 'limit'" style="margin-top:10px">
  47. <select-region :checkData.sync="allForm.region" :dataValue="allForm.region" />
  48. <!-- v-model="allForm.region" -->
  49. <!-- {{ getData('region') }} -->
  50. <!-- <el-cascader
  51. ref="cascaderRegion"
  52. v-decorator="['region', { rules: [{ required: true, message: '请选择地区' }] }]"
  53. :options="options"
  54. :props="optionProps"
  55. clearable
  56. filterable
  57. style="width:100%"
  58. @change="getRegion"
  59. ></el-cascader> -->
  60. </div>
  61. </a-form-item>
  62. <a-form-item
  63. label="年龄"
  64. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  65. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  66. >
  67. <a-radio-group v-model="allForm.ageType" buttonStyle="solid" @change="ageChange">
  68. <a-radio-button value="noLimit">不限</a-radio-button>
  69. <a-radio-button value="ageLimit">限定年龄段</a-radio-button>
  70. <a-radio-button value="ageCustom">自定义年龄段</a-radio-button>
  71. </a-radio-group>
  72. <div v-if="allForm.ageType == 'ageLimit'">
  73. <!-- v-model="allForm.ages_range" -->
  74. <a-checkbox-group v-decorator="['ages_range', { rules: [{ required: true, message: '请选择年龄段' }] }]">
  75. <a-checkbox value="0">0-11岁</a-checkbox>
  76. <a-checkbox value="12">12-27岁</a-checkbox>
  77. <a-checkbox value="18">18-23岁</a-checkbox>
  78. <a-checkbox value="24">24-30岁</a-checkbox>
  79. <a-checkbox value="31">31-40岁</a-checkbox>
  80. <a-checkbox value="41">41-49岁</a-checkbox>
  81. <a-checkbox value="50">50+</a-checkbox>
  82. </a-checkbox-group>
  83. </div>
  84. <div v-if="allForm.ageType == 'ageCustom'">
  85. <a-slider
  86. range
  87. :marks="marks"
  88. :min="5"
  89. :max="55"
  90. v-decorator="[
  91. 'age',
  92. {
  93. rules: [{ required: true, message: '请选择年龄段' }, { validator: handleConfirmValue }],
  94. initialValue: [10, 50]
  95. }
  96. ]"
  97. />
  98. </div>
  99. </a-form-item>
  100. <a-form-item
  101. label="性别"
  102. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  103. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  104. >
  105. <a-radio-group
  106. buttonStyle="solid"
  107. v-decorator="[
  108. 'gender',
  109. {
  110. initialValue: '0'
  111. }
  112. ]"
  113. >
  114. <a-radio-button value="0">不限</a-radio-button>
  115. <a-radio-button value="1">女性</a-radio-button>
  116. <a-radio-button value="2">男性</a-radio-button>
  117. </a-radio-group>
  118. </a-form-item>
  119. <a-form-item
  120. label="最低版本"
  121. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  122. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  123. >
  124. <a-radio-group
  125. buttonStyle="solid"
  126. v-decorator="[
  127. 'platform_os',
  128. {
  129. initialValue: '0'
  130. }
  131. ]"
  132. >
  133. <a-radio-button value="0" v-if="getApp == '0'">不限</a-radio-button>
  134. <a-radio-button value="1" v-if="getApp == '0' || getApp == '1'">Android系统</a-radio-button>
  135. <a-radio-button value="2" v-if="getApp == '0' || getApp == '2'">IOS系统</a-radio-button>
  136. <div v-if="getData('platform_os') == '1'" style="margin-top:10px">
  137. <a-radio-group
  138. v-decorator="[
  139. 'android_osv',
  140. {
  141. initialValue: '3'
  142. }
  143. ]"
  144. >
  145. <a-radio value="3">不限</a-radio>
  146. <a-radio value="4">4X+</a-radio>
  147. <a-radio value="5">5x+</a-radio>
  148. <a-radio value="6">6x+</a-radio>
  149. <a-radio value="7">7x+</a-radio>
  150. </a-radio-group>
  151. </div>
  152. <div v-if="getData('platform_os') == '2'" style="margin-top:10px">
  153. <a-radio-group
  154. v-decorator="[
  155. 'ios_osv',
  156. {
  157. initialValue: '6'
  158. }
  159. ]"
  160. >
  161. <a-radio value="6">不限</a-radio>
  162. <a-radio value="7">7X+</a-radio>
  163. <a-radio value="8">8x+</a-radio>
  164. <a-radio value="9">9x+</a-radio>
  165. <a-radio value="10">10x+</a-radio>
  166. </a-radio-group>
  167. </div>
  168. </a-radio-group>
  169. </a-form-item>
  170. <a-form-item
  171. v-if="getData('platform_os') != '2'"
  172. label="设备品牌"
  173. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  174. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  175. >
  176. <a-radio-group buttonStyle="solid" v-model="allForm.device">
  177. <a-radio-button value="0">不限</a-radio-button>
  178. <a-radio-button value="1">选择品牌</a-radio-button>
  179. </a-radio-group>
  180. <div v-if="allForm.device == '1'" style="width:120%">
  181. <a-checkbox-group
  182. v-decorator="['device_brand', { rules: [{ required: true, message: '请选择设备品牌' }] }]"
  183. style="width:120%"
  184. >
  185. <a-checkbox value="1">OPPO</a-checkbox>
  186. <a-checkbox value="2">VIVO</a-checkbox>
  187. <a-checkbox value="3">华为</a-checkbox>
  188. <a-checkbox value="4">小米</a-checkbox>
  189. <a-checkbox value="5">荣耀</a-checkbox>
  190. <a-checkbox value="6">三星</a-checkbox>
  191. <a-checkbox value="7">金立</a-checkbox>
  192. <a-checkbox value="8">魅族</a-checkbox>
  193. <a-checkbox value="9">乐视</a-checkbox>
  194. <a-checkbox value="10">其他</a-checkbox>
  195. <a-checkbox value="11" v-if="getData('platform_os') == '0'">苹果</a-checkbox>
  196. </a-checkbox-group>
  197. </div>
  198. </a-form-item>
  199. <a-form-item
  200. label="设备价格"
  201. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  202. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  203. >
  204. <a-radio-group buttonStyle="solid" v-model="allForm.price">
  205. <a-radio-button value="0">不限</a-radio-button>
  206. <a-radio-button value="1">选择价格</a-radio-button>
  207. </a-radio-group>
  208. <div v-if="allForm.price == '1'" style="width:120%">
  209. <a-checkbox-group
  210. v-decorator="['device_price', { rules: [{ required: true, message: '请选择设备价格' }] }]"
  211. style="width:120%"
  212. >
  213. <a-checkbox value="1">1500以下</a-checkbox>
  214. <a-checkbox value="2">1501~2000</a-checkbox>
  215. <a-checkbox value="3">2001~2500</a-checkbox>
  216. <a-checkbox value="4">2501~3000</a-checkbox>
  217. <a-checkbox value="5">3001~3500</a-checkbox>
  218. <a-checkbox value="6">3501~4000</a-checkbox>
  219. <a-checkbox value="7">4001~4500</a-checkbox>
  220. <a-checkbox value="8">4501~5000</a-checkbox>
  221. <a-checkbox value="9">5001~5500</a-checkbox>
  222. <a-checkbox value="10">5500以上</a-checkbox>
  223. </a-checkbox-group>
  224. </div>
  225. </a-form-item>
  226. <a-form-item
  227. label="APP行为"
  228. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  229. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  230. v-show="getData('platform_os') == '1'"
  231. >
  232. <a-radio-group buttonStyle="solid" v-model="allForm.appType" @change="getAppType">
  233. <a-radio-button value="0">不限</a-radio-button>
  234. <a-radio-button value="1">按分类</a-radio-button>
  235. <a-radio-button value="2">按APP名称</a-radio-button>
  236. </a-radio-group>
  237. </a-form-item>
  238. <a-form-item
  239. label=" "
  240. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  241. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  242. v-show="getData('platform_os') == '1' && allForm.appType == '1'"
  243. class="else-label"
  244. >
  245. <a-select
  246. mode="multiple"
  247. style="width: 100%"
  248. optionFilterProp="children"
  249. showSearch
  250. :filterOption="filterOption"
  251. v-decorator="['app_interest', { rules: [{ required: true, message: '请选择APP行为' }] }]"
  252. >
  253. <a-select-option v-for="item in optionsAppActive" :key="item.tagId" :value="item.tagId">{{
  254. item.tagName
  255. }}</a-select-option>
  256. </a-select>
  257. <!-- <el-cascader
  258. ref="cascader"
  259. v-decorator="['app_interest', { rules: [{ required: true, message: '请选择分类' }] }]"
  260. :options="optionsAppActive"
  261. :props="optionPropsApp"
  262. clearable
  263. filterable
  264. style="width:100%"
  265. ></el-cascader> -->
  266. </a-form-item>
  267. <a-form-item
  268. label=" "
  269. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  270. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  271. v-if="getData('platform_os') == '1' && allForm.appType == '2'"
  272. class="else-label"
  273. >
  274. <div style="position:relative;" v-clickoutside="handleClose">
  275. <a-input
  276. placeholder="请输入搜索内容"
  277. @change="getAppAll"
  278. @focus="getAppAll"
  279. style="width:100%;position:relative;"
  280. />
  281. <div
  282. style="width:100%;position:absolute;z-index:10;height:200px;background:white;overflow:auto;box-shadow: 0 2px 8px 0 rgba(0,0,0,.15);"
  283. v-if="closeDialog"
  284. >
  285. <ul>
  286. <li style="padding:0 10px">
  287. <a-checkbox
  288. style="float:left;margin:0 5px"
  289. @change="onCheckAllChange"
  290. :indeterminate="indeterminate"
  291. :checked="checkAll"
  292. ></a-checkbox
  293. >全选
  294. </li>
  295. <a-checkbox-group @change="onChange" v-model="checkArr" class="home-card" style="width:100%">
  296. <li style="padding:0 10px;width:100%;" v-for="item of optionsApp" :key="item.app_id">
  297. <a-checkbox :value="item.app_id" style="float:left;margin:0 5px"></a-checkbox>{{ item.app_name }}
  298. </li>
  299. </a-checkbox-group>
  300. </ul>
  301. </div>
  302. <div style="width:100%" v-if="checkArr.length > 0">
  303. <a-button @click="clearAll">清空</a-button>
  304. <br />
  305. <a-tag v-for="item of checkArr" :key="item" closable :afterClose="() => log(item)">
  306. {{ showAppName(item) }}
  307. </a-tag>
  308. </div>
  309. </div>
  310. </a-form-item>
  311. <a-form-item
  312. label="商业兴趣"
  313. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  314. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  315. >
  316. <a-radio-group
  317. buttonStyle="solid"
  318. @change="businessInterest"
  319. v-decorator="[
  320. 'business_interest_type',
  321. {
  322. initialValue: '0'
  323. }
  324. ]"
  325. >
  326. <a-radio-button value="0">不限</a-radio-button>
  327. <a-radio-button value="2">兴趣标签</a-radio-button>
  328. </a-radio-group>
  329. </a-form-item>
  330. <a-form-item
  331. label=" "
  332. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  333. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  334. class="else-label"
  335. v-show="getData('business_interest_type') == '2'"
  336. >
  337. <a-select
  338. mode="multiple"
  339. style="width: 100%"
  340. optionFilterProp="children"
  341. showSearch
  342. :filterOption="filterOption"
  343. v-decorator="['business_interest', { rules: [{ required: true, message: '请选择商业兴趣' }] }]"
  344. >
  345. <a-select-option v-for="item in businessOptions" :key="item.tagId" :value="item.tagId">{{
  346. item.tagName
  347. }}</a-select-option>
  348. </a-select>
  349. </a-form-item>
  350. <a-form-item
  351. label="网络环境"
  352. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  353. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  354. >
  355. <a-radio-group
  356. buttonStyle="solid"
  357. v-decorator="[
  358. 'network',
  359. {
  360. initialValue: '0'
  361. }
  362. ]"
  363. >
  364. <a-radio-button value="0">不限</a-radio-button>
  365. <a-radio-button value="1">Wi-Fi</a-radio-button>
  366. <a-radio-button value="2">移动网络</a-radio-button>
  367. </a-radio-group>
  368. </a-form-item>
  369. <a-form-item
  370. label="网红粉丝"
  371. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  372. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  373. >
  374. <a-radio-group buttonStyle="solid" v-model="allForm.fansStar" @change="fansStar">
  375. <a-radio-button value="0">不限</a-radio-button>
  376. <a-radio-button value="1">网红类别</a-radio-button>
  377. </a-radio-group>
  378. </a-form-item>
  379. <a-form-item
  380. label=" "
  381. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  382. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  383. class="else-label"
  384. v-if="allForm.fansStar == '1'"
  385. >
  386. <a-select
  387. mode="multiple"
  388. style="width: 100%"
  389. optionFilterProp="children"
  390. showSearch
  391. :filterOption="filterOption"
  392. v-decorator="['fans_star', { rules: [{ required: true, message: '请选择网红类别' }] }]"
  393. >
  394. <a-select-option v-for="item in fansStarOptions" :key="item.tagId" :value="item.tagId">{{
  395. item.tagName
  396. }}</a-select-option>
  397. </a-select>
  398. </a-form-item>
  399. <a-form-item
  400. label="兴趣视频用户"
  401. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  402. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  403. >
  404. <a-radio-group buttonStyle="solid" v-model="allForm.interestVideo" @change="interestVideo">
  405. <a-radio-button value="0">不限</a-radio-button>
  406. <a-radio-button value="1">视频标签</a-radio-button>
  407. </a-radio-group>
  408. </a-form-item>
  409. <a-form-item
  410. label=" "
  411. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  412. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  413. class="else-label"
  414. v-if="allForm.interestVideo == '1'"
  415. >
  416. <a-select
  417. mode="multiple"
  418. style="width: 100%"
  419. optionFilterProp="children"
  420. showSearch
  421. :filterOption="filterOption"
  422. v-decorator="['interest_video', { rules: [{ required: true, message: '请选择视频标签' }] }]"
  423. >
  424. <a-select-option v-for="item in interestVideoOptions" :key="item.tagId" :value="item.tagId">{{
  425. item.tagName
  426. }}</a-select-option>
  427. </a-select>
  428. </a-form-item>
  429. <a-form-item
  430. label="智能扩量"
  431. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  432. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  433. >
  434. <a-radio-group
  435. buttonStyle="solid"
  436. v-decorator="[
  437. 'is_open',
  438. {
  439. initialValue: '0'
  440. }
  441. ]"
  442. @change="interestVideo"
  443. >
  444. <a-radio-button value="0">关闭</a-radio-button>
  445. <a-radio-button value="1">开启</a-radio-button>
  446. </a-radio-group>
  447. </a-form-item>
  448. <a-form-item
  449. label=" "
  450. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  451. :wrapperCol="{ lg: { span: 10 }, sm: { span: 17 } }"
  452. class="else-label"
  453. v-if="getData('is_open') == '1'"
  454. >
  455. <a-checkbox
  456. :disabled="allForm.ageType != 'ageCustom'"
  457. v-decorator="[
  458. 'no_age_break',
  459. {
  460. initialValue: false
  461. }
  462. ]"
  463. >不可突破年龄</a-checkbox
  464. >
  465. <a-checkbox
  466. :disabled="getData('gender') == '0'"
  467. v-decorator="[
  468. 'no_gender_break',
  469. {
  470. initialValue: false
  471. }
  472. ]"
  473. >不可突破性别</a-checkbox
  474. >
  475. <a-checkbox
  476. :disabled="allForm.regionType != 'limit'"
  477. v-decorator="[
  478. 'no_area_break',
  479. {
  480. initialValue: false
  481. }
  482. ]"
  483. >不可突破地域</a-checkbox
  484. >
  485. </a-form-item>
  486. </a-form>
  487. </template>
  488. <script>
  489. import { getAction, postAction } from '@/api/manage'
  490. import moment from 'moment'
  491. import { mapGetters } from 'vuex'
  492. import jq from 'jquery'
  493. import selectRegion from './selectRegion'
  494. import pick from 'lodash.pick'
  495. let dateQuantumRangeConst = ''
  496. const clickoutside = {
  497. // 初始化指令
  498. bind(el, binding, vnode) {
  499. function documentHandler(e) {
  500. // 这里判断点击的元素是否是本身,是本身,则返回
  501. if (el.contains(e.target)) {
  502. return false
  503. }
  504. // 判断指令中是否绑定了函数
  505. if (binding.expression) {
  506. // 如果绑定了函数 则调用那个函数,此处binding.value就是handleClose方法
  507. binding.value(e)
  508. }
  509. }
  510. // 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
  511. el.__vueClickOutside__ = documentHandler
  512. document.addEventListener('click', documentHandler)
  513. },
  514. update() {},
  515. unbind(el, binding) {
  516. // 解除事件监听
  517. document.removeEventListener('click', el.__vueClickOutside__)
  518. delete el.__vueClickOutside__
  519. }
  520. }
  521. export default {
  522. name: 'BaseForm',
  523. components: { selectRegion },
  524. props: {
  525. campaignId: {
  526. type: String,
  527. default() {
  528. return null
  529. }
  530. },
  531. platform: {
  532. default() {
  533. return null
  534. }
  535. },
  536. populationData: {}
  537. },
  538. watch: {
  539. platform(n, o) {
  540. console.log(n, o)
  541. if (n == 1 || n == 2) {
  542. // platform_os
  543. this.form.setFieldsValue({ platform_os: '1' })
  544. } else if (n == 3 || n == 4) {
  545. this.form.setFieldsValue({ platform_os: '2' })
  546. } else {
  547. this.form.setFieldsValue({ platform_os: '0' })
  548. }
  549. }
  550. },
  551. directives: { clickoutside },
  552. data() {
  553. return {
  554. form: this.$form.createForm(this),
  555. marks: {
  556. 5: '5岁',
  557. 10: '10岁',
  558. 15: '15岁',
  559. 20: '20岁',
  560. 25: '25岁',
  561. 30: '30岁',
  562. 35: '35岁',
  563. 40: '40岁',
  564. 45: '45岁',
  565. 50: '50岁',
  566. 55: '55岁'
  567. },
  568. step: 0,
  569. loading: false,
  570. checkArr: [],
  571. checkAll: false,
  572. allForm: {
  573. regionType: 'noLimit',
  574. region: [],
  575. ageType: 'noLimit',
  576. ages_range: [],
  577. age: [],
  578. device: '0',
  579. price: '0',
  580. appType: '0',
  581. fansStar: '0',
  582. interestVideo: '0'
  583. },
  584. options: [],
  585. optionsAll: [],
  586. optionProps: {
  587. value: 'regionId',
  588. label: 'name',
  589. children: 'children',
  590. multiple: true,
  591. emitPath: false
  592. // checkStrictly: true
  593. },
  594. optionsApp: [],
  595. optionsAppActive: [],
  596. checkOptions: [],
  597. businessOptions: [],
  598. fansStarOptions: [],
  599. interestVideoOptions: [],
  600. optionPropsApp: {
  601. value: 'tagId',
  602. label: 'tagName',
  603. children: 'children',
  604. multiple: true,
  605. emitPath: false
  606. },
  607. getApp: '0',
  608. closeDialog: false,
  609. indeterminate: false,
  610. checkAll: false
  611. }
  612. },
  613. computed: {},
  614. methods: {
  615. getRegion(data) {
  616. this.$refs.cascaderRegion.getCheckedNodes()
  617. console.log(this.$refs.cascaderRegion.getCheckedNodes())
  618. var dataName = this.$refs.cascaderRegion.getCheckedNodes()
  619. var jsonArr = data
  620. for (let i = 0; i < dataName.length; i++) {
  621. for (let j = 0; j < data.length; j++) {
  622. if (dataName[i].children.length > 0) {
  623. if (data[j].substring(0, 2) == dataName[i].value) {
  624. jsonArr.splice(j, 1)
  625. }
  626. }
  627. }
  628. }
  629. console.log(jsonArr)
  630. },
  631. showAppName(appId) {
  632. var data = this.checkOptions.filter(item => {
  633. return item.app_id == appId
  634. })
  635. return data[0].app_name
  636. },
  637. log(appId) {
  638. var index = this.checkArr.findIndex(item => item === appId)
  639. this.checkArr.splice(index, 1)
  640. if (this.checkArr.length == 0) {
  641. this.indeterminate = false
  642. this.checkAll = false
  643. }
  644. },
  645. handleClose(e) {
  646. this.closeDialog = false
  647. },
  648. clearAll() {
  649. this.checkArr = []
  650. this.indeterminate = false
  651. this.checkAll = false
  652. },
  653. onChange(checkedList) {
  654. this.indeterminate =
  655. !!checkedList.length &&
  656. checkedList.length <
  657. this.optionsApp.map(item => {
  658. return item.app_id
  659. }).length
  660. this.checkAll =
  661. checkedList.length ===
  662. this.optionsApp.map(item => {
  663. return item.app_id
  664. }).length
  665. },
  666. onCheckAllChange(e) {
  667. Object.assign(this, {
  668. checkArr: e.target.checked
  669. ? this.optionsApp.map(item => {
  670. return item.app_id
  671. })
  672. : [],
  673. indeterminate: false,
  674. checkAll: e.target.checked
  675. })
  676. if (this.checkArr.length > 20) {
  677. this.$message.error('最多选择20个APP行为')
  678. this.checkArr = []
  679. this.indeterminate = false
  680. this.checkAll = false
  681. }
  682. // if (this.checkAll) {
  683. // this.checkArr = []
  684. // } else {
  685. // this.checkArr = this.optionsApp.map(item => {
  686. // return item.app_id
  687. // })
  688. // }
  689. // this.checkAll = !this.checkAll
  690. },
  691. handleSubmit() {
  692. // e.preventDefault()
  693. this.form.validateFields((err, values) => {
  694. if (!err) {
  695. console.log('Received values of form: ', values)
  696. // this.checkArr
  697. var json = {}
  698. if (this.allForm.appType == '2') {
  699. json.app_ids = this.checkArr
  700. }
  701. if (this.allForm.regionType == 'limit') {
  702. json.region = this.allForm.region.map(item => {
  703. return item.value
  704. })
  705. }
  706. var dataJson = {
  707. ...values,
  708. ...json,
  709. no_age_break: values.no_age_break ? 1 : 0,
  710. no_gender_break: values.no_gender_break ? 1 : 0,
  711. no_area_break: values.no_area_break ? 1 : 0,
  712. allForm: this.allForm
  713. }
  714. this.$emit('update:populationData', dataJson)
  715. }
  716. })
  717. },
  718. handleConfirmValue(rule, value, callback) {
  719. console.log(value)
  720. if (Math.abs(value[0] - value[1]) < 5) {
  721. callback('自定义年龄段需要间隔大于5岁')
  722. }
  723. callback()
  724. },
  725. manyValidator(rule, value, callback) {
  726. if (value.length > 20) {
  727. callback('最多只能选择20个选项')
  728. }
  729. callback()
  730. },
  731. regionChange() {
  732. this.allForm.region = []
  733. // getAction('/kuaishou/batch/getRegion').then(res => {
  734. // console.log(res)
  735. // this.options = res.result
  736. // this.optionsAll = res.result
  737. // })
  738. },
  739. ageChange() {
  740. this.allForm.ages_range = []
  741. },
  742. search(e) {},
  743. put() {
  744. var data = this.allForm.region.map(item => {
  745. return item[1] + ''
  746. })
  747. console.log(data)
  748. var dataElse = data.map(item => {
  749. return [item.substring(0, 2), item]
  750. })
  751. console.log(dataElse)
  752. },
  753. getAppAll(e) {
  754. console.log(e.target.value)
  755. if (e.target.value !== '') {
  756. getAction('/kuaishou/batch/getAppSearch', {
  757. accountId: localStorage.getItem('accountId'),
  758. appName: e.target.value
  759. }).then(res => {
  760. if (res.result) {
  761. this.optionsApp = res.result
  762. this.checkOptions.push(...res.result)
  763. this.closeDialog = true
  764. } else {
  765. this.optionsApp = []
  766. this.closeDialog = false
  767. }
  768. })
  769. } else {
  770. this.optionsApp = []
  771. this.closeDialog = false
  772. }
  773. },
  774. getAppType(e) {
  775. console.log(e.target.value)
  776. this.optionsApp = []
  777. this.form.setFieldsValue({ app_interest: [] })
  778. this.checkArr = []
  779. if (e.target.value == '1') {
  780. getAction('/kuaishou/batch/getTargetList', { tagType: 'APP_INTEREST' }).then(res => {
  781. console.log(res)
  782. if (res.success) {
  783. this.optionsApp = res.result
  784. }
  785. })
  786. }
  787. },
  788. businessInterest(e) {
  789. this.form.setFieldsValue({ business_interest: [] })
  790. if (e.target.value == '2') {
  791. this.getDataType('BUSINESS_INTEREST', 'businessOptions')
  792. }
  793. },
  794. fansStar(e) {
  795. if (e.target.value == '1') {
  796. this.getDataType('FANS_STAR', 'fansStarOptions')
  797. }
  798. },
  799. interestVideo(e) {
  800. if (e.target.value == '1') {
  801. this.getDataType('INTEREST_VIDEO', 'interestVideoOptions')
  802. }
  803. },
  804. filterOption(input, option) {
  805. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  806. },
  807. getDataType(type, dataList) {
  808. getAction('/kuaishou/batch/getTargetList', { tagType: type }).then(res => {
  809. console.log(res)
  810. if (res.success) {
  811. this[dataList] = res.result
  812. }
  813. })
  814. },
  815. getData(className) {
  816. return this.form.getFieldValue(className)
  817. }
  818. },
  819. mounted: function() {
  820. this.getDataType('APP_INTEREST', 'optionsAppActive')
  821. this.getDataType('BUSINESS_INTEREST', 'businessOptions')
  822. this.getDataType('FANS_STAR', 'fansStarOptions')
  823. this.getDataType('INTEREST_VIDEO', 'interestVideoOptions')
  824. if (this.populationData.allForm) {
  825. this.allForm = this.populationData.allForm
  826. this.$nextTick(() => {
  827. // setTimeout(() => {
  828. console.log(this.populationData)
  829. this.form.setFieldsValue(
  830. pick(this.populationData, [
  831. 'business_interest_type',
  832. 'fans_star',
  833. 'interest_video',
  834. 'app_interest',
  835. 'platform_os',
  836. 'is_open',
  837. 'gender',
  838. 'network',
  839. 'ages_range',
  840. 'android_osv',
  841. 'device_brand',
  842. 'device_price',
  843. 'no_age_break',
  844. 'no_gender_break',
  845. 'no_area_break',
  846. 'business_interest'
  847. ])
  848. )
  849. // }, 100)
  850. // setTimeout(() => {
  851. // console.log(this.populationData)
  852. // this.form.setFieldsValue(pick(this.populationData, ['app_interest', 'business_interest']))
  853. // }, 100)
  854. })
  855. }
  856. }
  857. }
  858. var box_id
  859. var StartTD = null
  860. var StartIndex = null
  861. var EndTD = null
  862. var EndIndex = null
  863. var Selected = 'Selected'
  864. var Start_x = null
  865. var Start_y = null
  866. //点击中表格的小时值
  867. var hour
  868. //点击选中的星期值
  869. var week
  870. //1为这个格子在此次鼠标拖拽过程中被选中(不执行选中方法),0为没选中过
  871. var td_state = 0
  872. //生成星期数组
  873. var num = ['一', '二', '三', '四', '五', '六', '日']
  874. //生成时间值数组
  875. var arr_hour = get_hour_arr()
  876. //按下鼠标左键拖动选中单元格
  877. function SelectTD(StartIndex, EndIndex, Selected) {
  878. var MinX = null
  879. var MaxX = null
  880. var MinY = null
  881. var MaxY = null
  882. var coordinate = get_coordinate(StartIndex, EndIndex)
  883. MinX = coordinate[0]
  884. MaxX = coordinate[1]
  885. MinY = coordinate[2]
  886. MaxY = coordinate[3]
  887. for (var i = MinY; i <= MaxY; i++) {
  888. for (var j = MinX; j <= MaxX; j++) {
  889. var SelectTR = jq('#' + box_id + ' table tbody tr ').eq(i)
  890. var td_class = jq('td', SelectTR)
  891. .eq(j)
  892. .attr('class')
  893. td_state = jq('td', SelectTR)
  894. .eq(j)
  895. .attr('td_state')
  896. //在同一次鼠标按下的过程中,选中过的表格不进行选中或取消操作
  897. if (!td_state) {
  898. if (td_class == Selected) {
  899. jq('td', SelectTR)
  900. .eq(j)
  901. .removeClass(Selected)
  902. } else {
  903. //筛选掉标明为星期的表格
  904. jq('td', SelectTR)
  905. .eq(j)
  906. .attr('class', Selected)
  907. }
  908. jq('td', SelectTR)
  909. .eq(j)
  910. .attr('td_state', '1')
  911. }
  912. }
  913. }
  914. //改变二进制值
  915. get_time_val()
  916. //改变日期显示
  917. convert_date()
  918. }
  919. //点击选中或去掉选中整行、整列
  920. function SelectTD_click(StartIndex, EndIndex, Selected) {
  921. var MinX = null
  922. var MaxX = null
  923. var MinY = null
  924. var MaxY = null
  925. var Selected_true = 0
  926. var Selected_false = 0
  927. var coordinate = get_coordinate(StartIndex, EndIndex)
  928. MinX = coordinate[0]
  929. MaxX = coordinate[1]
  930. MinY = coordinate[2]
  931. MaxY = coordinate[3]
  932. //列出此列当中的表格选中状态
  933. for (var i = MinY; i <= MaxY; i++) {
  934. for (var j = MinX; j <= MaxX; j++) {
  935. var SelectTR = jq('#' + box_id + ' table tbody tr ').eq(i)
  936. var td_class = jq('td', SelectTR)
  937. .eq(j)
  938. .attr('class')
  939. if (td_class == Selected) {
  940. //表格里存在已选中的元素
  941. Selected_true = 1
  942. } else {
  943. //表格里存在未选中的元素
  944. Selected_false = 1
  945. }
  946. }
  947. }
  948. //执行选中或去掉选中方法
  949. for (var i = MinY; i <= MaxY; i++) {
  950. for (var j = MinX; j <= MaxX; j++) {
  951. var SelectTR = jq('#' + box_id + ' table tbody tr ').eq(i)
  952. var td_class = jq('td', SelectTR)
  953. .eq(j)
  954. .attr('class')
  955. //一列当中存在已选中与未选中的表格处理:整列全部选中
  956. if (Selected_true == 1 && Selected_false == 1) {
  957. jq('td', SelectTR)
  958. .eq(j)
  959. .attr('class', Selected)
  960. } else if (Selected_false == 1) {
  961. //一列当中只存在未选中的表格处理:整列全部选中
  962. jq('td', SelectTR)
  963. .eq(j)
  964. .attr('class', Selected)
  965. } else {
  966. //一列当中只存在已选中的表格处理:整列全部去掉选中
  967. jq('td', SelectTR)
  968. .eq(j)
  969. .removeClass(Selected)
  970. }
  971. }
  972. }
  973. //改变二进制值
  974. get_time_val()
  975. //改变日期显示
  976. convert_date()
  977. }
  978. //获取选中范围的开始与结束的坐标
  979. function get_coordinate(StartIndex, EndIndex) {
  980. var MinX = null
  981. var MaxX = null
  982. var MinY = null
  983. var MaxY = null
  984. if (StartIndex.x < EndIndex.x) {
  985. MinX = StartIndex.x
  986. MaxX = EndIndex.x
  987. } else {
  988. MinX = EndIndex.x
  989. MaxX = StartIndex.x
  990. }
  991. if (StartIndex.y < EndIndex.y) {
  992. MinY = StartIndex.y
  993. MaxY = EndIndex.y
  994. } else {
  995. MinY = EndIndex.y
  996. MaxY = StartIndex.y
  997. }
  998. return [MinX, MaxX, MinY, MaxY]
  999. }
  1000. //改变二进制值
  1001. function get_time_val() {
  1002. var time_type = ''
  1003. jq('#' + box_id + ' table tbody')
  1004. .find('td')
  1005. .each(function(k) {
  1006. var Selected_type = jq(this).attr('class')
  1007. var week = jq(this).attr('week')
  1008. if (Selected_type == Selected && !week) {
  1009. time_type += '1'
  1010. } else if (!week) {
  1011. time_type += '0'
  1012. }
  1013. })
  1014. jq('#' + box_id + '_time_num').val(time_type)
  1015. // convert_date();
  1016. }
  1017. //二进制数转换日期
  1018. function convert_date(external_binary) {
  1019. //初始化周数数组
  1020. var time_week_arr = []
  1021. if (!external_binary) {
  1022. //内部调用,进行选中表格和输出时间操作。
  1023. var binary = jq('#' + box_id + '_time_num').val()
  1024. } else {
  1025. //存在外部参入传入,此函数进行返回时间操作。
  1026. var date_html = ''
  1027. var binary = external_binary
  1028. }
  1029. for (var y = 0; y < 7; y++) {
  1030. //初始化小时数组
  1031. var time_hour_arr = []
  1032. for (var x = 0; x < 24; x++) {
  1033. //获取当前点击元素的位置
  1034. if (y == 0) {
  1035. var index = x
  1036. } else {
  1037. var index = y * 24 + x
  1038. }
  1039. //获取td对应的二进制值
  1040. var Selected_val = binary.charAt(index)
  1041. if (Selected_val == 1) {
  1042. //组装保存进数组里
  1043. if (time_hour_arr == []) {
  1044. //表格的第一个位置的值
  1045. time_hour_arr = arr_hour[x]
  1046. } else if (binary.charAt(index - 1) == 1 && binary.charAt(index - 2) == 1) {
  1047. //此位置(包含上一行)的前两个都为选中时
  1048. if (x == 0 && binary.charAt(index + 1) == 0) {
  1049. //选中行里第一个,后一个表格没选中,加逗号
  1050. time_hour_arr[time_hour_arr.length] = arr_hour[x] + ', '
  1051. } else if (x == 0 && binary.charAt(index + 1) == 1) {
  1052. //选中行里第一个,后一个表格已选中,不加逗号
  1053. time_hour_arr[time_hour_arr.length] = arr_hour[x]
  1054. } else if (x == 1 && binary.charAt(index - 1) == 0) {
  1055. //选中行里第二个,上一个表格没选中,加逗号
  1056. time_hour_arr[time_hour_arr.length] = arr_hour[x] + ', '
  1057. } else if (x == 1 && binary.charAt(index - 1) == 1) {
  1058. //选中行里第二个,上一个表格已选中,前加-号,后加逗号
  1059. time_hour_arr[time_hour_arr.length] = '-' + arr_hour[x] + ', '
  1060. } else {
  1061. //选中行里除第一、二的表格以外,前一个表格已经选中,此元素前加- 后加逗号
  1062. time_hour_arr[time_hour_arr.length - 1] = '-' + arr_hour[x] + ', '
  1063. }
  1064. } else if (binary.charAt(index - 1) == 1 && x > 0) {
  1065. //选中的前一个已选中,且此次选中的不是行里第一个,此次选中的元素前加-后加逗号
  1066. time_hour_arr[time_hour_arr.length] = '-' + arr_hour[x] + ', '
  1067. } else if (binary.charAt(index + 1) != 1 || x == 23) {
  1068. //选中的后一个没选中,或者此次选中的是行里最后一个,此次选中的元素加逗号
  1069. time_hour_arr[time_hour_arr.length] = arr_hour[x] + ', '
  1070. } else {
  1071. //选中的后一已选中,此次选中的元素不加逗号
  1072. time_hour_arr[time_hour_arr.length] = arr_hour[x]
  1073. }
  1074. }
  1075. }
  1076. time_week_arr[y] = time_hour_arr
  1077. }
  1078. // console.info(box_id);
  1079. if (!external_binary) {
  1080. jq('#' + box_id + '_time_seled').html('')
  1081. }
  1082. //再次组装并输出数组
  1083. var time_html = []
  1084. for (var y = 0; y < 7; y++) {
  1085. for (var x = 0; x < time_week_arr[y].length; x++) {
  1086. if (!time_html[y]) {
  1087. time_html[y] = time_week_arr[y][x]
  1088. } else {
  1089. time_html[y] += time_week_arr[y][x]
  1090. }
  1091. }
  1092. if (time_html[y]) {
  1093. time_html[y] = time_html[y].substring(0, time_html[y].length - 2)
  1094. if (!external_binary) {
  1095. jq('#' + box_id + '_time_seled').append('<div>星期' + num[y] + ' (' + time_html[y] + ')' + '</div>')
  1096. } else {
  1097. date_html += '星期' + num[y] + ' (' + time_html[y] + ')' + ', '
  1098. }
  1099. }
  1100. }
  1101. if (external_binary) {
  1102. return date_html
  1103. }
  1104. // console.info(time_html);
  1105. }
  1106. //生成时间值数组
  1107. function get_hour_arr() {
  1108. var arr_hour = []
  1109. var oDate = new Date('2016/07/01 00:00:00') //实例一个时间对象;
  1110. var oDate_hour = oDate.getHours()
  1111. var oDate_minute = oDate.getMinutes()
  1112. for (var i = 0; i < 24; i++) {
  1113. if (oDate_minute < 10) {
  1114. var oDate_minute = '0' + oDate_minute
  1115. }
  1116. if (i >= 1) {
  1117. oDate.setMinutes(oDate.getMinutes() + 60)
  1118. oDate_hour = oDate.getHours()
  1119. oDate_minute = oDate.getMinutes()
  1120. if (oDate_minute < 10) {
  1121. var oDate_minute = '0' + oDate_minute
  1122. }
  1123. }
  1124. arr_hour[i] = oDate_hour + ':' + oDate_minute
  1125. }
  1126. return arr_hour
  1127. }
  1128. //更新操作
  1129. function renewal(id) {
  1130. if (id) {
  1131. box_id = id
  1132. }
  1133. //解绑鼠标移动监听事件
  1134. jq('#' + box_id + ' table tbody tr td').unbind('mouseover')
  1135. //初始化表格的在此次选中状态
  1136. jq('#' + box_id + ' table tbody tr td').attr('td_state', '')
  1137. //改变二进制值
  1138. get_time_val()
  1139. //改变日期显示
  1140. convert_date()
  1141. }
  1142. //二进制数赋值选中表格
  1143. function binary_selected() {
  1144. var default_time_val = jq('#' + box_id + ' .default_time_val').val()
  1145. if (default_time_val) {
  1146. for (var i = 0; i < 168; i++) {
  1147. var td_selected = default_time_val.charAt(i)
  1148. if (td_selected != 0) {
  1149. jq('#' + box_id + ' table tbody tr td')
  1150. .eq(i)
  1151. .attr('class', 'Selected')
  1152. //更新操作,显示文字形日期
  1153. renewal()
  1154. }
  1155. }
  1156. }
  1157. }
  1158. //实例化程序
  1159. function load_time_table(id, value) {
  1160. //包住table的元素id
  1161. box_id = id
  1162. var html
  1163. html = '<input type="hidden" class="default_time_val" value="' + value + '"/>'
  1164. html +=
  1165. '<table cellspacing="0" cellpadding="0" border="0" class="plug-timer-grid" onselectstart="return false" onselect="document.selection.empty()">'
  1166. html += '<thead>'
  1167. html += '<tr>'
  1168. html += '<th></th>'
  1169. html += '<th colSpan="12">上午</th>'
  1170. html += '<th colSpan="12">下午</th>'
  1171. html += '</tr>'
  1172. html += '<tr class="hour">'
  1173. html += '<th></th>'
  1174. html += '</tr>'
  1175. html += '</thead>'
  1176. html += '<tbody></tbody>'
  1177. html += '</table>'
  1178. html += '<input class="focus" type="hidden" style="opacity: 0;">'
  1179. html += '<div id="' + box_id + '_time_seled" style="line-height: 15px;font-size:10px;"></div>'
  1180. html +=
  1181. '<input type="hidden" id="' +
  1182. box_id +
  1183. '_time_num" name="time" caption="每日投放时段" switchname="selectTime" value="' +
  1184. value +
  1185. '">'
  1186. jq('#' + box_id).html('')
  1187. jq('#' + box_id).append(html)
  1188. var html_tbody_td = ''
  1189. var html_thead_td = ''
  1190. //创建表格
  1191. for (var i = 0; i < 7; i++) {
  1192. var week = i + 1
  1193. html_tbody_td += '<tr>'
  1194. for (var j = 0; j < 25; j++) {
  1195. if (j == 0) {
  1196. html_tbody_td += '<th week="' + week + '">星期' + num[i] + '</th>'
  1197. } else {
  1198. html_tbody_td += '<td>' + '</td>'
  1199. }
  1200. }
  1201. html_tbody_td += '</tr>'
  1202. }
  1203. //创建表格小时栏目
  1204. for (var i = 0; i <= 23; i++) {
  1205. html_thead_td += '<td hour="' + i + '">' + i + '</td>'
  1206. }
  1207. jq('#' + box_id + ' table thead .hour').append(html_thead_td)
  1208. jq('#' + box_id + ' table tbody').html(html_tbody_td)
  1209. //检查是否有赋有二进制值,如有,将选中相应的表格
  1210. binary_selected()
  1211. //控制器,控制当前在哪个表格进行操作
  1212. jq('.plug-timer-grid').hover(function(e) {
  1213. if (1 != e.which) {
  1214. //判断是否为左击
  1215. var id = jq(this)
  1216. .parent()
  1217. .attr('id')
  1218. box_id = id
  1219. }
  1220. })
  1221. //清除所有选中项
  1222. jq('.clear').click(function() {
  1223. jq(this)
  1224. .parent()
  1225. .find('td')
  1226. .removeClass(Selected)
  1227. var id = jq(this)
  1228. .parent()
  1229. .attr('id')
  1230. renewal(id)
  1231. })
  1232. //点击小时选中或去掉整列处理块
  1233. jq('#' + box_id + ' table thead tr td').click(function() {
  1234. hour = jq(this).attr('hour')
  1235. if (hour >= 0) {
  1236. var rows = jq('#' + box_id + ' table tbody tr').length
  1237. Start_x = jq(this).index() * 2 - 1
  1238. Start_y = 0
  1239. StartIndex = { x: Start_x, y: Start_y }
  1240. EndTD = jq(this)
  1241. var x = jq(this).index() * 2 - 2
  1242. var y = rows - 1 //为了配合for计算公式-1
  1243. EndIndex = { x: x, y: y }
  1244. //改变第一次按下鼠标时候的改变选中状态
  1245. SelectTD_click(StartIndex, EndIndex, Selected)
  1246. }
  1247. })
  1248. //点击星期选中或去掉整行处理块
  1249. jq('#' + box_id + ' table tbody tr th').click(function() {
  1250. var week = jq(this).attr('week')
  1251. if (week >= 0) {
  1252. var line = jq('#' + box_id + ' table tbody tr td').length / jq('#' + box_id + ' table tbody tr').length
  1253. Start_x = 0
  1254. Start_y = jq(this)
  1255. .parent()
  1256. .index()
  1257. StartIndex = { x: Start_x, y: Start_y }
  1258. EndTD = jq(this)
  1259. var y = jq(this)
  1260. .parent()
  1261. .index()
  1262. var x = line - 1 //为了配合for计算公式-1
  1263. EndIndex = { x: x, y: y }
  1264. //改变第一次按下鼠标时候的改变选中状态
  1265. SelectTD_click(StartIndex, EndIndex, Selected)
  1266. }
  1267. })
  1268. //监听鼠标按下事件(鼠标按下左键拖动选中处理块)
  1269. jq('#' + box_id + ' table tbody tr td')
  1270. .unbind('mousedown')
  1271. .bind('mousedown', function() {
  1272. //记录刚开始点击的元素位置
  1273. Start_x = jq(this).index() - 1
  1274. Start_y = jq(this)
  1275. .parent()
  1276. .index()
  1277. StartIndex = { x: Start_x, y: Start_y }
  1278. EndTD = jq(this)
  1279. var x = jq(this).index() - 1
  1280. var y = jq(this)
  1281. .parent()
  1282. .index()
  1283. EndIndex = { x: x, y: y }
  1284. //改变第一次按下鼠标时候的改变选中状态
  1285. SelectTD(StartIndex, EndIndex, Selected)
  1286. StartTD = jq(this)
  1287. StartIndex = { x: Start_x, y: Start_y }
  1288. //监听鼠标移动事件,实现改变后续鼠标拖拽时候的表格选中状态
  1289. jq('#' + box_id + ' table tbody tr td').mouseover(function(e) {
  1290. EndTD = jq(this)
  1291. var x = jq(this).index() - 1
  1292. var y = jq(this)
  1293. .parent()
  1294. .index()
  1295. EndIndex = { x: x, y: y }
  1296. if (1 != e.which) {
  1297. //判断是否为左击
  1298. jq('#' + box_id + ' table tbody tr td').unbind('mouseover')
  1299. }
  1300. //去除停留在td上的光标
  1301. jq('#' + box_id + ' .focus').focus()
  1302. SelectTD(StartIndex, EndIndex, Selected)
  1303. })
  1304. //放开鼠标左键时,初始化相关参数和解绑相关监听
  1305. jq('html')
  1306. .unbind('mouseup')
  1307. .bind('mouseup', function() {
  1308. renewal()
  1309. })
  1310. })
  1311. }
  1312. /*外部调用接口*/
  1313. //解绑鼠标松开监听事件
  1314. function unbundle_mouseover() {
  1315. jq('html').unbind('mouseup')
  1316. }
  1317. /*二进制获取转换后的时间*/
  1318. function get_time_html(binary) {
  1319. return convert_date(binary)
  1320. }
  1321. jq(function() {
  1322. load_time_table('table_time_selected1', this.dateQuantumRange)
  1323. })
  1324. </script>
  1325. <style type="text/css">
  1326. .plug-timer-grid {
  1327. width: 100%;
  1328. }
  1329. .plug-timer-grid td,
  1330. .plug-timer-grid th {
  1331. border: 1px solid #97b4d1;
  1332. text-align: center; /*cursor:pointer;*/
  1333. font-size: 10px;
  1334. line-height: 10px;
  1335. }
  1336. .Selected {
  1337. background-color: rgb(102, 162, 243);
  1338. opacity: 0.5;
  1339. }
  1340. .plug-timer-grid {
  1341. border-collapse: collapse;
  1342. z-index: 4;
  1343. }
  1344. .plug-timer-grid thead tr {
  1345. display: table-row;
  1346. vertical-align: inherit;
  1347. border-color: inherit;
  1348. }
  1349. .group-creat table td {
  1350. height: 20px;
  1351. max-width: 5px;
  1352. border: 1px solid #dfe6ec;
  1353. font-size: 12px;
  1354. text-align: center;
  1355. vertical-align: middle;
  1356. overflow: hidden;
  1357. transition: background 0.5s;
  1358. -webkit-transition: background 0.5s;
  1359. }
  1360. .plug-timer-grid tbody th {
  1361. width: 4%;
  1362. }
  1363. .plug-timer-grid tbody tr td {
  1364. width: 2%;
  1365. }
  1366. /*.clear{*/
  1367. /* margin:20px 0px 20px 0px;*/
  1368. /*}*/
  1369. </style>